Hello,
How can I redirect your code to the buddypress registration page instead of 404 error page
/** * Hide Members Directory from non members(not logged in users) */ function buddydev_hide_members_directory_for_non_members() { if ( bp_is_members_directory() && ! is_user_logged_in() ) { bp_do_404(); load_template( get_404_template() ); exit( 0 ); } } add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_for_non_members' );
I think I found a solution I got it to work for both members directory page and single members page with this code.
/** * Hide Members Directory and single members page from non members(not logged in users) */ function buddydev_hide_members_directory_for_non_members() { if ( bp_is_members_directory() || bp_is_user() ) { if (!is_user_logged_in() ) { bp_core_redirect( bp_get_signup_page() ); exit; } } } add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_for_non_members' );
Hi Tosin,
Yes, That will work 🙂You may remove the ‘exit’ line as ‘bp_core_redirect’ does it for us. Still, keeping it is not going to harm.
Regards
Brajesh
Viewing 3 posts - 1 through 3 (of 3 total)
The topic ‘ [Resolved] Hide BuddyPress members directory from non logged users(non members)’ is closed to new replies.
This topic is: resolved