Tagged: redirect non-logged in users
Hey there,
What php code do I need to add in the buddypress custom to redirect not logged in users to login IF accessing buddypress pages (such as profile and site-wide activity)?
Thank you
Hi Kristian,
Thank you for the question.You may use the following code.
/** * Restrict access to BuddyPress for non logged users completely. */ function buddydev_restrict_bp_pages() { // If Logged in // Or not on BuddyPress pages // Or it is register/activation page // Do not restrict. if ( is_user_logged_in() || ! is_buddypress() || bp_is_register_page() || bp_is_activation_page() ) { return; } bp_core_redirect( wp_login_url() ); } add_action( 'bp_template_redirect', 'buddydev_restrict_bp_pages' );
Hope that helps.
Regards
BrajeshThank you Brajesh!
By the way, only yours works when the Youzer devs offered their code.
You really are a master in what you do.
Thank you so much sir.
It’s such an honor to know to you :,)
Kristian
Hi Kristian,
Thank you for the kind words. I am honoured.I am thankful to have members like you.
Have a great day.
Brajesh
The topic ‘ [Resolved] redirecting not logged in users to login IF accessing buddypress pages (profile)’ is closed to new replies.