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);

Pin It on Pinterest

Share This

Share This

Share this post with your friends!