Notifications
Clear all

Limited Support

Our support team is currently on holiday from December 25, 2025 to January 7, 2026, and replies may be delayed during this period.

We appreciate your patience and understanding while our team is away. Thank you for being part of the gVectors community!

Merry Christmas and Happy Holidays! 🎄

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

5 Posts
2 Users
1 Reactions
2,181 Views
(@salubritas)
Active Member
Joined: 6 years ago
Posts: 15
Topic starter  

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 🙂  



   
Quote
Elvina
(@elvina)
Support
Joined: 6 years ago
Posts: 1403
 

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)
Active Member
Joined: 6 years ago
Posts: 15
Topic starter  

Thank you Elvina, I will look into that.



   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 6 years ago
Posts: 1403
 

@salubritas

yes, please keep us informed.



   
ReplyQuote
(@salubritas)
Active Member
Joined: 6 years ago
Posts: 15
Topic starter  

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 reacted
ReplyQuote
Share:
Scroll to top