WordPress.org

Make WordPress Core

Ticket #6286: 6286.diff

File 6286.diff, 2.5 KB (added by ryan, 3 years ago)

Moderation notification for post authors

  • wp-includes/pluggable.php

     
    10051005        $moderating_user = wp_get_current_user(); 
    10061006        $moderating_uid = (int) $user->id; 
    10071007 
     1008        if ( $comment->user_id == $post->post_author ) return false; // The comment was left by the author. 
    10081009 
    1009         if ( $comment->user_id == $post->post_author ) return false; // The comment was left by the author. 
    1010         
    10111010        if ( $user->user_id == $moderating_uid ) return false; // The author moderated a comment on his own post 
    10121011 
    10131012        if ('' == $user->user_email) return false; // If there's no email to send the comment to 
     
    10991098function wp_notify_moderator($comment_id) { 
    11001099        global $wpdb; 
    11011100 
    1102         if( get_option( "moderation_notify" ) == 0 ) 
     1101        if ( 0 == get_option( 'moderation_notify' ) ) 
    11031102                return true; 
    11041103 
    1105         $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID=%d LIMIT 1", $comment_id)); 
    1106         $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID=%d LIMIT 1", $comment->comment_post_ID)); 
     1104        $comment = get_comment($comment_id); 
     1105        $post = get_post($comment->comment_post_ID); 
     1106        $user = get_userdata( $post->post_author ); 
     1107        // Send to the administation and to the post author if the author can modify the comment. 
     1108        $email_to = array( get_option('admin_email') ); 
     1109        if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) ) 
     1110                $email_to[] = $user->user_email; 
    11071111 
    11081112        $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); 
    11091113        $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); 
     
    11511155        $notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n"; 
    11521156 
    11531157        $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title ); 
    1154         $admin_email = get_option('admin_email'); 
    11551158        $message_headers = ''; 
    11561159 
    11571160        $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id); 
    11581161        $subject = apply_filters('comment_moderation_subject', $subject, $comment_id); 
    11591162        $message_headers = apply_filters('comment_moderation_headers', $message_headers); 
    11601163 
    1161         @wp_mail($admin_email, $subject, $notify_message, $message_headers); 
     1164        foreach ( $email_to as $email ) 
     1165                @wp_mail($email, $subject, $notify_message, $message_headers); 
    11621166 
    11631167        return true; 
    11641168}