Prevent moderated users from commenting on WP blog
-
Hi Michael,
I am trying to put together a bit of code to prevent moderated users from commenting in the regular WP blog pages.
Desired function:
– regular users not affected.
– moderated users can view blog pages, can view comments left by others, but comment box is hidden from them and they are shown “Comments are closed” message.My code is below, seems to work as desired on my test site. Would you please be kind enough to take a look in case I am making some errors? I’m not a coder so I need a thumbs up (or down) before I add it to my live site.
I appreciate your help, thank you.
function remove_comment_box_if_moderated() { $current_user = bp_loggedin_user_id(); if ( bp_registration_get_moderation_status( $current_user ) ) { add_filter( 'comments_open' , '__return_false' ); } else { add_filter( 'comments_open' , '__return_true' ); } } add_filter( 'init' , 'remove_comment_box_if_moderated' );
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Prevent moderated users from commenting on WP blog’ is closed to new replies.