Support » Plugins » hack for email notification to threaded comment au

  • so i love the threaded comments hack by LaughingLizard and hope it gets into the main package soon. but i don’t like that it doesn’t notify authors of comments when there is a reply to their post.
    here’s a hack that provides that functionality, to be applied after you apply the threaded comments hack.
    in wp-includes/functions.php:
    change line
    function wp_notify_postauthor($comment_id, $comment_type='comment') {

    to be
    function wp_notify_postauthor($comment_id, $comment_type='comment', $comment_reply_ID='') {

    change line
    if ('' == $user->user_email) return false; // If there's no email to send the comment to

    to be
    if ('' == $user->user_email && 'reply' != $comment_type) return false; // If there's no email to send the comment to or if it's a reply

    insert after
    if ('comment' == $comment_type) {

    the following lines
    $comment_reply = $wpdb->get_row("SELECT comment_reply_ID FROM $tablecomments WHERE comment_ID = '$comment_id'");
    $comment_reply_ID = $comment_reply->comment_reply_ID;
    if($comment_reply_ID != '') wp_notify_postauthor($comment_id, 'reply', $comment_reply_ID);

    insert after
    $subject = '[' . $blogname . '] Pingback: "' .stripslashes($post->post_title).'"';

    the following lines
    elseif ('reply' == $comment_type) {
    $mail_row = $wpdb->get_row("SELECT comment_author_email FROM $tablecomments WHERE comment_ID = $comment_reply_ID");
    $mail_addr = $mail_row->comment_author_email;
    if('' == $mail_addr) return false;
    $notify_message = "New reply to your comment #$comment->comment_reply_ID in post \"".stripslashes($post->post_title)."\"\r\n\r\n";
    $notify_message .= "Author : $comment->comment_author\r\n";
    $notify_message .= "Website: $comment->comment_author_url\r\n";
    $notify_message .= "Comment:\r\n".stripslashes($comment->comment_content)."\r\n\r\n";
    $notify_message .= "You can see all comments on this post here: \r\n";
    $subject = '[' . $blogname . '] Comment: "' .stripslashes($post->post_title).'"';

    let me know if it works/doesn’t work for you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Nice development!
    I have a quick question though. Your submit comment script says that the emails submitted won’t be seen by anyone, but I can see the email address of folks that have left comments in the link with their name as “”.
    So these email addresses are visible to the world at large, as such, isn’t it?
    Another point – Maybe you could have a question
    “would you like to receive emails when replies are posted?” Yes/No
    so people can submit their email as always and then choose not to get an automated email when a comment is posted.
    And – would emails be sent to only when replies to the same comment are posted, or also when someone leaves a reply to a comment posted in response to the comment. (quite involved, but I hope you see what I mean.)
    🙂 I was just thinking about the lack of this email notify feature in threaded comments yesterday.
    Thanks, I will probably get it working soon.

    so i can’t tell what you’re talking about. the hack itself doesn’t that that; just the comments post page on my site says that, because i hide the commenter’s emails.
    also, the features suggested in the other post of this hack (screwed up special characters though, so i reposted here) would be awesome, but i don’t have time to implement them. the person that suggested them has some great ideas and should definitely implement them!

    I got error on line 1514.
    I’m using 1.0.1 at the moment, should I upgrade to 1.0.2 first?

    what’s the error (and the lines around the line that failed)?

    2fargon – your comment about the email not being displayed is a”problem” with WP… if the commentor does not enter a URL, then their address gets turned into a mailto link instead of a link to their website. The way I’d like to see it done is to have a setting that allows me to force a name and address (at a minimum, with a web addr optional). Then when comments are displayed, if they supplied a URL link, then their name would get converted to a link, if they didn’t then just display their name un-linked to anything.

    Thanks, TG, maybe this should be brought to the attention of the devs(I don’t know if you are one 🙂 )

    Nope, but I just started a thread requesting that the name be un-linked in the event that no URL was submitted. Seems to only make sense to me.

    fwiw, that’s a good recommendation, i hope it gets implemented (along with threaded comments, replies like i have implemented, and a lot of other features that should have been in 1.0)…

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.