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

问题描述 投票:0回答:1

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

我想收到所有作者和编辑用户的评论通知,他们有能力审核评论。如何做到这一点?请你帮助我好吗??

wordpress plugins comments
1个回答
0
投票

我找到了答案!

我使用编辑器用户Role创建了新用户。要将您的通知发送给特定的新创建的编辑器用户我在代码后添加了编辑器用户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

这有效!

© www.soinside.com 2019 - 2024. All rights reserved.