Notifications
Clear all

Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:

 

wpDiscuz Support Forum   wpForo Support Forum

[Solved] How to not send comment subscription notifications to people who subscribed way back  

  RSS

Salubritas
(@salubritas)
Active Member
Joined: 1 year ago
Posts: 15
18/12/2019 8:55 pm  

What is a good solution to not sending comment subscription notifications to people who subscribed to notifications more than (for example) 6 months ago?

I have some posts which still get comments after months/years and people who subscribed to comments way back sometimes think the email notification is spam because they don't remember commenting or lost interest long ago.

Is there a filter that fires before comment subscription emails are sent, for example, that would allow me to check the age of the subscription and prevent the email being sent?

Or a filter that fires when a comment subscription is added that I could hook into and delete all comment subs older than X months?

Thanks Smile  


Quote
Elvina
(@elvina)
Noble Member Moderator
Joined: 10 months ago
Posts: 1177
19/12/2019 1:55 pm  

Hi @salubritas,

Below is provided the hook you should use:

wpdiscuz_email_notification

You should find the ID of the subscription(this is the second parametre), in the parameters of this hook. Then check out it in the wp_wc_comments_subscription table. If the subscribtion_type is a "comment" you should prevent the email sending.

Or a filter that fires when a comment subscription is added that I could hook into and delete all comment subs older than X months?

Also, there is a data type in the parameters you can use it to delete the old comments( older than 6 months).


ReplyQuote
Salubritas
(@salubritas)
Active Member
Joined: 1 year ago
Posts: 15
19/12/2019 3:03 pm  

Thank you Elvina, I will look into that.


ReplyQuote
Elvina
(@elvina)
Noble Member Moderator
Joined: 10 months ago
Posts: 1177
19/12/2019 3:19 pm  

@salubritas

yes, please keep us informed.


ReplyQuote
Salubritas
(@salubritas)
Active Member
Joined: 1 year ago
Posts: 15
19/12/2019 7:54 pm  

This seems to be working how I want:

// wpDiscuz: don't send comment subs notifications for subscriptions older than 6 months
function wr_wpdiscuz_email_notification($emailSender, $emailData, $comment) {
$sub_id = $emailData['id'];

global $wpdb;
$sql = $wpdb->prepare(
"SELECT COUNT(*) FROM wp_wc_comments_subscription where id = %d
AND DATE_ADD(subscription_date, INTERVAL 6 MONTH) > CURDATE()",
$sub_id
);
$sendMail = $wpdb->get_var($sql);

return $sendMail;
}
add_filter('wpdiscuz_email_notification', 'wr_wpdiscuz_email_notification', 10, 3);

Elvina liked
ReplyQuote
Share: