How to hide profile menu items from other users

Welcome mkmcst community Forum Web programming WordPress buddypress How to hide profile menu items from other users

Viewing 0 reply threads
  • Author
    Posts
    • #8854
      Michael Mc
      Keymaster
      @mkmcst
      function bpex_hide_profile_menu_tabs() {
      
      	if( bp_is_active( 'xprofile' ) ) :
      
      	if ( bp_is_user() && !is_super_admin() && !bp_is_my_profile() ) {
      	//	BP's profile main menu items. Comment those to show.
      	//	bp_core_remove_nav_item( 'activity' );
      		bp_core_remove_nav_item( 'profile' );
      		bp_core_remove_nav_item( 'friends' );
      		bp_core_remove_nav_item( 'groups' );
      	//	exist only if you use bbPress
      		bp_core_remove_nav_item( 'forums' ); 
      
      	//	BP's profile main menu items. Comment those to show.
      	//	bp_core_remove_subnav_item( 'activity', 'personnal' );
      		bp_core_remove_subnav_item( 'activity', 'mentions' );
      		bp_core_remove_subnav_item( 'activity', 'favorites' );
      		bp_core_remove_subnav_item( 'activity', 'friends' );
      		bp_core_remove_subnav_item( 'activity', 'groups' );
      	}
      	endif;
      }
      add_action( 'bp_setup_nav', 'bpex_hide_profile_menu_tabs', 15 );

      To hide tabs on groups, you need to specify the component. Note that all menu items (nav and subnav items) are considered as sub-nav, they have not the same distinction as on member or activity menus.

      Use another function for groups. Try this.

      function bpex_remove_group_tabs() {  
      
      	if ( ! bp_is_group() ) {
      		return;
      	}
      
      	$slug = bp_get_current_group_slug();
      
      		// hide items to all users except site admin
      	if ( !is_super_admin() ) {
      
      	//	bp_core_remove_subnav_item( $slug, 'members' );
      		bp_core_remove_subnav_item( $slug, 'send-invites' );
      	//	bp_core_remove_subnav_item( $slug, 'admin' );
      	//	bp_core_remove_subnav_item( $slug, 'forum' );
      	}
      
      }
      add_action( 'bp_actions', 'bpex_remove_group_tabs' );
      
      
Viewing 0 reply threads
  • You must be logged in to reply to this topic.