I am now able to block buddypress pages and redirect users to a page I choose

After a long saga I think I finally solve this mystery. I only took some guesses and got it working but if someone has a more elegant way of doing this then great! It is working as expected but I am not a coder.

Found my solution here


I modified Richie_KS codes since I want to disallow logged out users from all my buddypress pages and redirect them to my login page instead.

In functions.php I add this


function bp_guest_redirect() {

global $bp;

if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {

// enter the slug or component conditional here

if(!is_user_logged_in()) { // not logged in user

wp_redirect( get_option(‘siteurl’:wink: . ‘/signup’ );

} // user will be redirect to any link to want





This code also killed another bird.


I use BuddyPress Daily Child 3.9.6 theme and it works perfectly when a logged out user attempt any buddypress page searches using the sidebar search option. They are only redirected to my login page.

Any corrections to my code if necessary will be appreciated. I know if it ain’t broke I shouldn’t fix it but I hate to end up with problems down the road due to my poor coding skills.