Skip to:
Content
Pages
Categories
Search
Top
Bottom

set a default tab for non friends


  • MSoliman
    Participant

    @moefahmy

    hello buddies ,
    any idea how to change the default tap from activity to any other component for visitors ( non friend ) ?

Viewing 3 replies - 1 through 3 (of 3 total)

  • MSoliman
    Participant

    @moefahmy

    I’m using these code to hide taps for non friends members , the problem is . i need to hide the activity tap for non friends .. but without changing the default landing tab for the profile owner .. i want to dynamically set the landing tab for non friends to “profile” .. and for the profile owner to “activity”

    //remove profile tabs for non friends members//
    		function bpfr_maybe_hide_friends_nav_etc() {
    			$retval = false;
    			// condition 
    			if ( bp_is_user() && ! bp_is_my_profile() && ! friends_check_friendship( bp_displayed_user_id(), bp_loggedin_user_id() ) ) {
    				
    				$retval = true;
    			}	
    			return $retval;
    		}
    
    		function bpfr_hide_friends_nav_to_non_friends() {	
    			// stop if condition is not ok
    			if ( ! bpfr_maybe_hide_friends_nav_etc() ) {
    				return;
    			}
    			// otherwise we remove the nav items
    			// bp topnav items
    			
    			bp_core_remove_nav_item( 'groups' );
    			bp_core_remove_nav_item( 'activity' );
    			bp_core_remove_nav_item( 'events' );
    			bp_core_remove_nav_item( 'media' );
    			bp_core_remove_nav_item( 'profile' );
    			bp_core_remove_nav_item( 'friends' );
    			//bp subnav items
    			bp_core_remove_subnav_item( 'activity', 'friends' ); 
    			bp_core_remove_subnav_item( 'activity', 'mentions' ); 
    			
    		}
    		add_action( 'bp_ready', 'bpfr_hide_friends_nav_to_non_friends' );

    MSoliman
    Participant

    @moefahmy

    i have tried to redirect the non friends members to another tap “profile” instead of “activity” tab .. using the following code .. but it takes too long to redirect then i get “redirected you too many times” error

    function redirect_to_profile() {
    if ( bp_is_user() && ! bp_is_my_profile() && ! friends_check_friendship( bp_displayed_user_id(), bp_loggedin_user_id() ) ) {
    		global $bp;
    		bp_core_redirect( bp_displayed_user_domain() . 'resume' );
    		exit();
     }
     }
    add_action( 'bp_ready', 'redirect_to_profile' );

    please if someone just helping me to sorting this code .. i want just to set the default landing tab for non friends to profile instead of activity tab .. and keep activity tab a default landing tab for profiles owners

    What about using a custom member front page? Then you’d have total flexibility:
    Custom Front Pages for your users profiles

    Otherwise, I think you could conditionally filter bp_displayed_user_get_front_template to specify members/single/activity.php for self and friends and members/single/profile.php for non-friends. See this function:
    https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-members/bp-members-template.php#L1397

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar