Skip to content

Instantly share code, notes, and snippets.

@anandkumar
Created April 20, 2015 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandkumar/3d982bc9a22f739e04d9 to your computer and use it in GitHub Desktop.
Save anandkumar/3d982bc9a22f739e04d9 to your computer and use it in GitHub Desktop.
Hide bbPress forum replies with mesage
<?php
// Do not copy opening php tag
function bb_auth_reply_view( $reply_id ) {
$reply_id = bbp_get_reply_id( $reply_id );
// Check if password is required
if ( post_password_required( $reply_id ) )
return get_the_password_form();
$content = get_post_field( 'post_content', $reply_id );
// first topic reply shouldn't be hiding
$rep_position = bbp_get_reply_position($reply_id);
// if user is not logged in and not the first post topic
if( !is_user_logged_in() && $rep_position > 1 ) {
return "Replies only viewable for logged in users";
} else {
// return normal
return $content;
}
}
add_filter( 'bbp_get_reply_content', 'bb_auth_reply_view' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment