Hiding nav item not working as expected
-
WordPress 4.9.5 -> BuddyPress 2.9.4 -> Agama Blue Child Theme
I ended up with the below code from posts in these forums but it doesn’t do quite what I need it to do.
Users should not be able to see other users’ friends so the Friends tab when viewing another user’s profile page must be removed along with the functionality. Here’s my code:function bpfr_hide_tabs() { if ( !is_super_admin() && !bp_is_my_profile() ) { bp_core_remove_subnav_item( 'profile', 'friends' ); // This does nothing //bp_core_remove_nav_item( 'friends' ); //Or this but this also hides the Friends main menu item, not just the Friends tab in the user's profile page } } add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
I’ve switched between both options in the code.
bp_core_remove_subnav_item( 'profile', 'friends' );
doesn’t really do anything andbp_core_remove_nav_item( 'friends' );
does remove the Friends tab from another user’s profile but it also removes it from the main menu which is a different thing. The main menu Friends link points to my own Friends whereas the Friends tab in another user’s profile points to their friends. Any help would be appreciated.
- You must be logged in to reply to this topic.