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
This commit is contained in:
Andrew Nacin 2013-07-10 22:01:12 +00:00
parent 0c5811461a
commit 0f84b87380
1 changed files with 12 additions and 9 deletions

View File

@ -989,10 +989,6 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
$post = get_post( $comment->comment_post_ID ); $post = get_post( $comment->comment_post_ID );
$author = get_userdata( $post->post_author ); $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 // The comment was left by the author
if ( $comment->user_id == $post->post_author ) if ( $comment->user_id == $post->post_author )
return false; return false;
@ -1001,6 +997,10 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
if ( $post->post_author == get_current_user_id() ) if ( $post->post_author == get_current_user_id() )
return false; 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 there's no email to send the comment to
if ( '' == $author->user_email ) if ( '' == $author->user_email )
return false; 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 .= 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"; $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"; if ( user_can( $post->post_author, 'edit_comment', $comment_id ) ) {
else if ( EMPTY_TRASH_DAYS )
$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&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'])); $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));