Skip to content

Commit

Permalink
Remove email
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Oct 8, 2024
1 parent c196e34 commit 08e6c9f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
20 changes: 10 additions & 10 deletions public/class-post-anonymously-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function load_fourms_class() {
* side of the site.
*/
require_once POST_ANONYMOUSLY_PLUGIN_PATH . 'public/partials/forums/post-anonymously-public-render-notifications.php';
require_once POST_ANONYMOUSLY_PLUGIN_PATH . 'public/partials/forums/post-anonymously-public-render-emails.php';
// require_once POST_ANONYMOUSLY_PLUGIN_PATH . 'public/partials/forums/post-anonymously-public-render-emails.php';
}

/**
Expand All @@ -157,19 +157,19 @@ public function bp_init() {
*/
$this->load_class();

Post_Anonymously_Public_Save_Meta_Groups::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Save_Meta_Groups::instance( $this->plugin_name, $this->version )->hooks();

Post_Anonymously_Public_Render_Groups_Activity::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Groups_Activity::instance( $this->plugin_name, $this->version )->hooks();

Post_Anonymously_Public_Render_Groups_Activity_Comments::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Groups_Activity_Comments::instance( $this->plugin_name, $this->version )->hooks();

Post_Anonymously_Public_Render_Groups_Notifications::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Groups_Notifications::instance( $this->plugin_name, $this->version )->hooks();

Post_Anonymously_Public_Save_Meta_Forums::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Forums_Topic::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Forums_Reply::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Forums_Notifications::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Render_Forums_Emails::instance( $plugin_name, $version )->hooks();
Post_Anonymously_Public_Save_Meta_Forums::instance( $this->plugin_name, $this->version )->hooks();
Post_Anonymously_Public_Render_Forums_Topic::instance( $this->plugin_name, $this->version )->hooks();
Post_Anonymously_Public_Render_Forums_Reply::instance( $this->plugin_name, $this->version )->hooks();
Post_Anonymously_Public_Render_Forums_Notifications::instance( $this->plugin_name, $this->version )->hooks();
// Post_Anonymously_Public_Render_Forums_Emails::instance( $this->plugin_name, $this->version )->hooks();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function set_tokens( $formatted_tokens, $tokens, $bp_email ) {
$author_id = get_post_field( 'post_author', $topic_id );
$receiver_user_id = $formatted_tokens['receiver-user.id'];


return $formatted_tokens;
}
}
30 changes: 30 additions & 0 deletions public/partials/forums/post-anonymously-public-save-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,36 @@ public function hooks() {
add_action( 'bbp_new_reply_post_extras', array( $this, 'reply_post_update' ), 1, 1 );
add_action( 'bbp_new_reply_pre_extras', array( $this, 'skip_reply_activity' ) );

/**
* Stop email for the forums new activity of anonymou post.
*/
add_action( 'bp_send_email', array( $this, 'email_sending' ), 1000, 4 );

}

/**
* Do not send email for the anonymou post in groups
*/
public function email_sending( $email, $email_type, $to, $args ) {

if ( 'groups-new-discussion' != $email_type ) {
return;
}

if ( ! isset( $args['tokens']['discussion.id'] ) ) {
return;
}

$discussion_id = $args['tokens']['discussion.id'];
if ( ! isset( $discussion_id ) ) {
return;
}

if ( ! $this->_functions->is_anonymously_post( $discussion_id ) ) {
return;
}

$email->set_to( '' );
}

/**
Expand Down

0 comments on commit 08e6c9f

Please sign in to comment.