<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16223] trunk/wp-includes/pluggable.php:
  Send moderation emails to post author.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16223">16223</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-11-06 15:20:50 +0000 (Sat, 06 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Send moderation emails to post author. see <a href="http://trac.wordpress.org/ticket/6286">#6286</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludespluggablephp">trunk/wp-includes/pluggable.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludespluggablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pluggable.php (16222 => 16223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pluggable.php        2010-11-06 10:07:35 UTC (rev 16222)
+++ trunk/wp-includes/pluggable.php        2010-11-06 15:20:50 UTC (rev 16223)
</span><span class="lines">@@ -1005,9 +1005,8 @@
</span><span class="cx">         $moderating_user = wp_get_current_user();
</span><span class="cx">         $moderating_uid = (int) $user-&gt;id;
</span><span class="cx"> 
</span><ins>+        if ( $comment-&gt;user_id == $post-&gt;post_author ) return false; // The comment was left by the author.
</ins><span class="cx"> 
</span><del>-        if ( $comment-&gt;user_id == $post-&gt;post_author ) return false; // The comment was left by the author.
-       
</del><span class="cx">         if ( $user-&gt;user_id == $moderating_uid ) return false; // The author moderated a comment on his own post
</span><span class="cx"> 
</span><span class="cx">         if ('' == $user-&gt;user_email) return false; // If there's no email to send the comment to
</span><span class="lines">@@ -1099,11 +1098,16 @@
</span><span class="cx"> function wp_notify_moderator($comment_id) {
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        if( get_option( &quot;moderation_notify&quot; ) == 0 )
</del><ins>+        if ( 0 == get_option( 'moderation_notify' ) )
</ins><span class="cx">                 return true;
</span><span class="cx"> 
</span><del>-        $comment = $wpdb-&gt;get_row($wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;comments WHERE comment_ID=%d LIMIT 1&quot;, $comment_id));
-        $post = $wpdb-&gt;get_row($wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;posts WHERE ID=%d LIMIT 1&quot;, $comment-&gt;comment_post_ID));
</del><ins>+        $comment = get_comment($comment_id);
+        $post = get_post($comment-&gt;comment_post_ID);
+        $user = get_userdata( $post-&gt;post_author );
+        // Send to the administation and to the post author if the author can modify the comment.
+        $email_to = array( get_option('admin_email') );
+        if ( user_can($user-&gt;ID, 'edit_comment', $comment_id) &amp;&amp; !empty($user-&gt;user_email) &amp;&amp; ( get_option('admin_email') != $user-&gt;user_email) )
+                $email_to[] = $user-&gt;user_email;
</ins><span class="cx"> 
</span><span class="cx">         $comment_author_domain = @gethostbyaddr($comment-&gt;comment_author_IP);
</span><span class="cx">         $comments_waiting = $wpdb-&gt;get_var(&quot;SELECT count(comment_ID) FROM $wpdb-&gt;comments WHERE comment_approved = '0'&quot;);
</span><span class="lines">@@ -1151,14 +1155,14 @@
</span><span class="cx">         $notify_message .= admin_url(&quot;edit-comments.php?comment_status=moderated&quot;) . &quot;\r\n&quot;;
</span><span class="cx"> 
</span><span class="cx">         $subject = sprintf( __('[%1$s] Please moderate: &quot;%2$s&quot;'), $blogname, $post-&gt;post_title );
</span><del>-        $admin_email = get_option('admin_email');
</del><span class="cx">         $message_headers = '';
</span><span class="cx"> 
</span><span class="cx">         $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
</span><span class="cx">         $subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
</span><span class="cx">         $message_headers = apply_filters('comment_moderation_headers', $message_headers);
</span><span class="cx"> 
</span><del>-        @wp_mail($admin_email, $subject, $notify_message, $message_headers);
</del><ins>+        foreach ( $email_to as $email )
+                @wp_mail($email, $subject, $notify_message, $message_headers);
</ins><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>