May 5, 2008
Tip and Trick Editorial

Notification Emails Not Send After Comment Approval in WordPress 2.5 and 2.5.1

In WordPress 2.5 and WordPress 2.5.1, when the option is set to email post author whenever a comment is posted (comments_notify = 1), no notification email is generated or sent to notify the post author if the comment is held in moderation queue and is only approved later via edit-comments.php.

Prior to WordPress 2.5, an email is sent on approval to post author even if a comment is required to be approved and not posted instantly. However, notification that a comment is held for moderation and require administrator’s action to approve, delete or spam the message is working properly, with email sends to administrator’s email address (admin_email), not post author.

It’s a bug that has been introduced in WordPress 2.5, and slips into WordPress 2.5.1 when moderation.php functionality was moved into edit-comments.php. The bug will probably be fixed in WordPress 2.5.2 release. If you can’t wait, simply edit wp-includes/comment.php on WordPress blog directory on web server, and add the following lines of code:

Before:

break;
case 'approve':
$query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID = %d LIMIT 1", $comment_id);
break;
case 'spam':
$query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id);

After:

break;
case 'approve':
$query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID = %d LIMIT 1", $comment_id);
if ( get_option( 'comments_notify' ) == true ) {
wp_notify_postauthor( $comment );
}
break;
case 'spam':
$query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id);



  • taz

    maganda ang post na ito….

    tanong kolang sana, talaga bang ang ginagamit na e-mail sa admin ay wordpress? ex. wordpressa@yahoo.com, kapag kc may bagong users sa site ay nagpapada ng e-mail ang site at ang nakalagay na name sa address ay worpress pero yung e-mail address ay yung sa company ko…

    pwede koband malaman kung talagang wordpress ba talaga ang ginagamit sa mga new e-mail users notipikasyon?

    salamat…

  • rap indir

    thank you ;)

  • http://www.sooran.com Sooran

    tancks.

    This Post Helped me

    Good Time

  • http://www.turkrapci.com rap dinle

    Much thanks for sharing your solution!

  • http://annanta.com Annanta

    Hi friends,

    Check this out. (WordPress or phpBB not sending mails?)

    In your c-panel there is an icon called MXentry as shown in image below, click it wordpress mail not sending 1

    In the upper gray box there is a line (As shown in the image below) “Always accept mail locally even if the primary mx does not point to this server” in front of that there is a check box, If you enable this then all mails will come to local server in spite of MX changes, So Need to DISABLE this function.

    Admin Note: Should add your domain to /etc/remotedomains instead.

  • http://www.roblayton.net Rob Layton

    In case this doesn't work, or you need details on the the cPanel method, I wrote it all out at http://www.roblayton.net/archive/wordpress-not-se

    Good luck!

  • http://www.google.com mike

    Ldn2m0 hi! how you doin?

  • Marcin

    In 2.6.1 it should look as this:

    <code>

    case 'approve':

    $query = $wpdb->prepare("UPDATE wpdb->comments SET comment_approved='1' WHERE comment_ID = %d LIMIT 1", $comment_id);

    if ( get_option('comments_notify') == true ) {

    $comment = get_comment($comment_id);

    wp_notify_postauthor($comment_id, $comment->comment_type);

    }

    </code>

    The only change is adding:

    <code>

    == true

    </code>

  • http://www.mylot.com/BuyNowOnlin/ ordersomabuyg

    Wow Cool !

    Super Man

    Nice Site

  • http://ficial.wordpress.com/ Chris

    This WPMU behavior was driving me a bit nuts. Much thanks for sharing your solution!

  • http://zerocarbonista.com paul

    Thanks for the post 'admin' – I help manage a (non?)corporate blog, and my boss stopped getting email notifications since upgrading to 2.5.x – I do believe your suggested patch has fixed it.

    So, again thanks very much!

  • Guillermo Scharffeno

    Hello,

    Tried it. It did not work. Thanks anyways.

  • admin

    Try to just add in the additional lines (the difference).

  • Guillermo Scharffeno

    Hi,

    The code I posted is from 2.5.1. Do you think that replacing this code with the one you posted could fix this issue?

  • admin

    version 2.5.

  • Guillermo Scharffeno

    Hello,

    The code you printed under 'before' is different in that the one in wp-includes/comment.php. This is the code in comment.php:

    <code>case 'approve':

    $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";

    break;

    case 'spam':

    $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";</code>

    Which version of WP did you get that code from?