moderation - How to moderate (manually approve) comments of a specific (registered) User

I have a WordPress blog that gets a ton of comments. I have a freelancer that does support on the blog and replies to th

I have a WordPress blog that gets a ton of comments. I have a freelancer that does support on the blog and replies to these comments. In a tryout phase, though, I'd like the comments of this support person to be manually approved by me.

How could this be done? Hold comments of a specific user in the moderation queue until approved?

I have a WordPress blog that gets a ton of comments. I have a freelancer that does support on the blog and replies to these comments. In a tryout phase, though, I'd like the comments of this support person to be manually approved by me.

How could this be done? Hold comments of a specific user in the moderation queue until approved?

Share Improve this question edited Sep 12, 2019 at 8:39 Matthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges asked Sep 12, 2019 at 7:00 3DHardware3DHardware 111 bronze badge 1
  • Welcome to WordPress Development. I hope you find the answer(s) you are looking for. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. – Matthew Brown aka Lord Matt Commented Sep 12, 2019 at 8:17
Add a comment  | 

1 Answer 1

Reset to default 1

If you are comfortable with coding, you could try a custom filter based on the WP_Comment object. Perhaps something like the following:

function wpse_wp_insert_comment($id, $comment) {    
        // Add your user_id, or use email address instead.
        if ( empty($comment->comment_author ) || $comment->user_id!== 1 )
            wp_set_comment_status( $comment, 'hold' );
}
add_action('wp_insert_comment', 'wpse_wp_insert_comment', 10, 2);

-Or ...

// Same method, but using userdata to compare email address instead
function wpse_wp_insert_comment($id, $comment) {    
    $author = empty($comment->comment_author) ? NULL : get_userdata($comment->user_id);
    // Be sure to update this line with YOUR actual email address.
    if ( empty($comment->comment_author ) || $author->user_email!=="[email protected]" )
        wp_set_comment_status( $comment, 'hold' );
}
add_action('wp_insert_comment', 'wpse_wp_insert_comment', 10, 2);

Extrapolated from a Tom Mcfarlin article "Programmatically Mark a Comment as Unapproved". See the "Gotcha" warning he throws out regarding users' anticipated outcome vs actual manipulated results caused by this type of function.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745159430a4614322.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信