From 0f84b873806e14d0e22a730acbbce16b98c9ba86 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 10 Jul 2013 22:01:12 +0000 Subject: [PATCH] Do not notify the post author about comments if they are no longer a member of the blog. This updates [23294] to use capability checks to determine if the user can still edit a post, which works for super admins. Additionally, it hides Trash/Spam action links when the user is still a member of the blog but cannot (or can no longer) moderate the comment. fixes #23136. git-svn-id: http://core.svn.wordpress.org/trunk@24649 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 9e7ea94ac6..acfa2ddd77 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -989,10 +989,6 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) { $post = get_post( $comment->comment_post_ID ); $author = get_userdata( $post->post_author ); - // The post author is no longer a member of the blog - if ( ! is_user_member_of_blog( $post->post_author ) ) - return false; - // The comment was left by the author if ( $comment->user_id == $post->post_author ) return false; @@ -1001,6 +997,10 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) { if ( $post->post_author == get_current_user_id() ) return false; + // The post author is no longer a member of the blog + if ( ! user_can( $post->post_author, 'read_post', $post->ID ) ) + return false; + // If there's no email to send the comment to if ( '' == $author->user_email ) return false; @@ -1045,11 +1045,14 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) { } $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; $notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n"; - if ( EMPTY_TRASH_DAYS ) - $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; - else - $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; - $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n"; + + if ( user_can( $post->post_author, 'edit_comment', $comment_id ) ) { + if ( EMPTY_TRASH_DAYS ) + $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; + else + $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; + $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n"; + } $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));