From 08e6c9f1bf788058be1c06bac55cb92644b0e7ed Mon Sep 17 00:00:00 2001 From: raftaar1191 Date: Tue, 8 Oct 2024 15:18:49 +0530 Subject: [PATCH] Remove email --- public/class-post-anonymously-public.php | 20 ++++++------- .../post-anonymously-public-render-emails.php | 1 - .../post-anonymously-public-save-meta.php | 30 +++++++++++++++++++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/public/class-post-anonymously-public.php b/public/class-post-anonymously-public.php index e92190a..b8154dc 100644 --- a/public/class-post-anonymously-public.php +++ b/public/class-post-anonymously-public.php @@ -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'; } /** @@ -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(); } diff --git a/public/partials/forums/post-anonymously-public-render-emails.php b/public/partials/forums/post-anonymously-public-render-emails.php index 573e62a..ac7a92c 100644 --- a/public/partials/forums/post-anonymously-public-render-emails.php +++ b/public/partials/forums/post-anonymously-public-render-emails.php @@ -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; } } diff --git a/public/partials/forums/post-anonymously-public-save-meta.php b/public/partials/forums/post-anonymously-public-save-meta.php index c28a7ac..a6fd8c4 100644 --- a/public/partials/forums/post-anonymously-public-save-meta.php +++ b/public/partials/forums/post-anonymously-public-save-meta.php @@ -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( '' ); } /**