Do you want your users to have comment notifications on all posts or just certain posts?
I was able to accomplish all posts by creating a new column in the wordpress _users table.
I basically just “duplicated” the comment_subscribe column from the wordpress _comments table and put it in the _users table.
Then in the plugin code, which you can edit from the plugins page in the dashboard (I would suggest backing up the original code before editing), there is a function send_notifications that calls another function subscriptions_from_post. I duplicated that function (function subscriptions_from_post) and changed it from this:
function subscriptions_from_post($postid) {
if ( is_array($this->post_subscriptions[$postid]) )
return $this->post_subscriptions[$postid];
global $wpdb;
$postid = (int) $postid;
$this->post_subscriptions[$postid] = $wpdb->get_col("SELECT comment_author_email FROM $wpdb->comments WHERE comment_post_ID = '$postid' AND comment_subscribe='Y' AND comment_author_email != '' AND comment_approved = '1' GROUP BY LCASE(comment_author_email)");
$subscribed_without_comment = (array) get_post_meta($postid, '_sg_subscribe-to-comments');
$this->post_subscriptions[$postid] = array_merge((array) $this->post_subscriptions[$postid], (array) $subscribed_without_comment);
$this->post_subscriptions[$postid] = array_unique($this->post_subscriptions[$postid]);
return $this->post_subscriptions[$postid];
}
to this:
function subscriptions_from_users($postid) {
if ( is_array($this->post_subscriptions[$postid]) )
return $this->post_subscriptions[$postid];
global $wpdb;
$postid = (int) $postid;
$this->post_subscriptions[$postid] = $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE comment_subscribe='Y' AND user_email != '' GROUP BY LCASE(user_email)");
$subscribed_without_comment = (array) get_post_meta($postid, '_sg_subscribe-to-comments');
$this->post_subscriptions[$postid] = array_merge((array) $this->post_subscriptions[$postid], (array) $subscribed_without_comment);
$this->post_subscriptions[$postid] = array_unique($this->post_subscriptions[$postid]);
return $this->post_subscriptions[$postid];
}
(don’t forget to change the function that is called in function send_notifications)
$subscriptions = $this->subscriptions_from_post($comment->comment_post_ID);
to
$subscriptions = $this->subscriptions_from_users($comment->comment_post_ID);
Now when a comment is posted, it looks for comment_subscribe column to be ‘Y’ in the _users table and then pulls the user(s)’s email address(es) from the same row(s) so now it sends emails to any users that have comment_subscribe = ‘Y’
If you want to choose which posts the users receive comments from you could create a new table called _comment_notifications with columns “comment_post_ID”, “users_email” and “comment_subscribe”. Then you can insert a row in the new _comment_notifications table with the user’s email, post ID, and then set the comment_subscribe to ‘Y’ or ‘N’. Now for the function you could call something like this:
function subscriptions_from_comment_notifications($postid) {
if ( is_array($this->post_subscriptions[$postid]) )
return $this->post_subscriptions[$postid];
global $wpdb;
$postid = (int) $postid;
$this->post_subscriptions[$postid] = $wpdb->get_col("SELECT users_email FROM $wpdb->comment_notifications WHERE comment_post_ID = '$postid' AND comment_subscribe='Y' AND users_email != '' GROUP BY LCASE(users_email)");
$subscribed_without_comment = (array) get_post_meta($postid, '_sg_subscribe-to-comments');
$this->post_subscriptions[$postid] = array_merge((array) $this->post_subscriptions[$postid], (array) $subscribed_without_comment);
$this->post_subscriptions[$postid] = array_unique($this->post_subscriptions[$postid]);
return $this->post_subscriptions[$postid];
}
(don’t forget to change the function that is called in function send_notifications)
Now notifications will be sent to any user you have inserted into the new table _comment_notifications with comment_subscribe set to ‘Y’