How to hiding / redirect users page from non logged in users ?

Wordpress buddypress non member

Here the simple step to protect your WordPress BuddyPress member only pages. Add this simple snippet into your theme’s ‘functions.php‘ file. That’s it..

The below snippet sample will redirect the visitor if the visitor is not logged in & trying to visit the sensitive BuddyPress pages.

Will redirect non-logged-in users trying to access private content to your front page or home page

//Hide for non-logged-in users (public visitors)
function bp_logged_out_page_template_redirect() { if( ! is_user_logged_in() && is_page( 'members' )|| is_page( 'activity' ) || bp_is_user()  ) { wp_redirect( home_url( '' ) ); exit(); } } add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );
4 thoughts on “How to redirect users, WordPress BuddyPress hide page from non-members, Non-Loggedin users..”

Leave a Reply

Your email address will not be published. Required fields are marked *