From 3714a915a2240cfbaae7159617288d58241d78ca Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 25 Sep 2015 05:36:32 +0000 Subject: [PATCH] Send comment approval notification to post author via hook. This is part of the project of #33587. Moving this particular message to the 'wp_set_comment_status' action has the added bonus that the notification is sent after the comment status has been updated in the database. Previously, a database error could lead to a case where an approval notification is sent, but the comment status change fails for some reason. Props mrmist, NickDuncan. Fixes #14078. git-svn-id: https://develop.svn.wordpress.org/trunk@34537 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-functions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wp-includes/comment-functions.php b/src/wp-includes/comment-functions.php index 56e91b1f54..2c399e7c43 100644 --- a/src/wp-includes/comment-functions.php +++ b/src/wp-includes/comment-functions.php @@ -1770,9 +1770,7 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) case 'approve': case '1': $status = '1'; - if ( get_option('comments_notify') ) { - wp_notify_postauthor( $comment_id ); - } + add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' ); break; case 'spam': $status = 'spam';