Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Yet another question about making BP Private.

  • @foodin65

    Participant

    Okay, I’ve got a question.

    I’ve read pretty much every post and page on the internet pertaining to making Buddypress private. I’ve tried a bunch of things, and I’ve even had some success.

    What I’m trying to accomplish is to make every single aspect of a Buddypress install private, while keeping the WP Pages & Posts open to guests and visitors.

    
    /**** Private Community****/
    
    function bp_guest_redirect() {
    	
    	global $bp;
    
    	if ( bp_is_profile_component() || bp_is_activity_component() || bp_is_blogs_component() || bp_is_messages_component() || bp_is_friends_component() || 	bp_is_groups_component() || bp_is_settings_component() || bp_is_member() || bp_is_directory() ) { // enter the slug or component conditional here
    		
    		if (!is_user_logged_in() ){ // not logged in user
    
    			bp_core_redirect( $bp->root_domain .'/please-log-in'); // user will be redirect to any link to want
    			
    		} 
    	}
    }
    
    add_filter('get_header','bp_guest_redirect',1);

    This code is supposed to redirect a user to my “/please-log-in” page whenever a guest tries to access any part of the Buddypress section of the site. It does work on almost every part of Buddypress… except the Members Directory. I need to know what I need to add to my if statement so the redirect works for the Member’s directory as well. Thanks in advance.

    Thanks for you help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @foodin65

    Participant

    Another note. This code is in my bp_custom.php file. I’d like to keep it there.

    @nuprn1

    Participant

    something like: (just taken from bp-core.php line 397)

    is_null( $bp->displayed_user->id ) && $bp->current_component == BP_MEMBERS_SLUG && $bp->is_directory

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Yet another question about making BP Private.’ is closed to new replies.
Skip to toolbar