最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Email notification to an email address other than admin for custom type post comments in wordpress

programmeradmin4浏览0评论

I have a customer post type called video. I want wordpress to send an email notification to one user who is going to check and approve the comments, when ever someone comments on that post type video.

Please help me how to set it up.

Below code is not working and also custom post type is missing

//Custom notification
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', '615895' );

    // 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 );

发布评论

评论列表(0)

  1. 暂无评论