我似乎不明白为什么要取消对评论的处理,调用我的“approve\\u comment\\u callback”操作。
有什么想法吗?我只是不希望它在我取消评论时同时发送两封电子邮件。
以下是两个(邮件)功能似乎相互冲突。。。
// Send mail to user when their comment has been restored
function untrash_answer_notification($comment_id) {
$comment = get_comment($comment_id);
if ( $comment->comment_parent != 0 ) return;
$author = get_userdata($comment->user_id);
$headers = "MIME-Version: 1.0" . "\\r\\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\\r\\n";
$headers .= "From: Blabla.com <[email protected]>" . "\\r\\n";
$subject = "Your comment was restored";
$message = "blabla";
wp_mail($author->user_email, $subject, $message, $headers);
}
add_action( \'untrash_comment\', \'untrash_answer_notification\' );
// Mail author if/when they\'re comment is approved
function approve_comment_callback($new_status, $old_status, $comment) {
if($old_status != $new_status) {
if($new_status == \'approved\' || $new_status==1) {
if($comment->comment_author_email!=\'\'){
$author = get_userdata($comment->user_id);
$headers = "MIME-Version: 1.0" . "\\r\\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\\r\\n";
$headers .= "From: Blabla.com <[email protected]>" . "\\r\\n";
$subject = "Your comment was approved";
$message = "blabla";
wp_mail($author->user_email, $subject, $message, $headers);
}
}
}
}
add_action(\'transition_comment_status\', \'approve_comment_callback\', 10,3);