• Hello everyone,

    I’m using WP for a school project. Sometimes we get bad spam comments, which are visible for students in the backend. To avoid this I’d like to hide and / or block access to pending / unapproved comments based on user-roles in the backend, i. e. in the comments section and (if possible) the icon / number in the admin-bar.

    I set up a comments black-list already, but this isn’t really reliable. I also searched the web for another solution (WP settings / permissions / plugin / code), but didn’t find any working ideas so far. Can anyone here suggest a solution, e. g. some code to be added to functions.php?

    I’m not a WP-developer myself but feel safe to make modifications to my child theme files.

    Thank you and best Regards,
    Oliver

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi,

    I have written some code that returns some placeholder text when displaying comments, this way the experience with using wordpress is the same but unapproved comments just always have this standard text.

    By approving the comment the true content would be unveiled.

    function fully_censor_unapproved_comment_content($comment_content, $comment, $args){
       if($comment->comment_approved){return $comment_content;}
       return "Lorem Ipsum Dolor";
    }
    add_filter( 'get_comment_text', 'fully_censor_unapproved_comment_content', 10, 3 );

    Please let me know if this behavior is acceptable or if you want something changed.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide / block access to pending comments based on user-role’ is closed to new replies.