评论通知电子邮件发送给编辑者用户角色

Comment Notification Email Send to Editor User role

在 wordpress 中,作者只会收到他们作为“作者”的帖子的评论通知,并且可以调节评论。 编辑仅会收到他们作为“作者”的帖子的评论通知,但可以审核任何评论。

我想收到所有作者和编辑用户的评论通知,他们有能力审核 comment.How 来执行此操作?你能帮帮我吗??

我找到答案了!

我使用编辑器用户创建了新用户Role.To 将您的通知发送给特定的新创建编辑器用户我在代码后添加了编辑器用户 ID“5”。

function se_comment_moderation_recipients( $emails, $comment_id ) {
    $comment = get_comment( $comment_id );
    $post = get_post( $comment->comment_post_ID );
    $user = get_user_by( 'id', '5' );

    // Return only the post author if the author can modify.
    if ( user_can( $user->ID, 'edit_published_posts' ) && ! empty( $user->user_email ) ) {
        $emails = array( $user->user_email );
    }

    return $emails;
}
add_filter( 'comment_moderation_recipients', 'se_comment_moderation_recipients', 11, 2 );
add_filter( 'comment_notification_recipients', 'se_comment_moderation_recipients', 11, 2 );

Reference

这有效!