BuddyDev

Search

Slug to use to remove the “profile” subnav menu item.

Tagged: 

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49013

    Hi there, I have been trying to remove the “profile” subnav menu item.

    Apparently the slug is “public” but that or none of the other slugs I have tried in this code snippet works?

    What slug should I insert to make it work?

    function bp_remove_nav_item() {
        global $bp;
        bp_core_remove_subnav_item( $bp->profile->slug, '  ?  ' );
    }
    add_action( 'wp', 'bp_remove_nav_item' );

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #49014

    Hi Carsten,
    This works fine for me.

    
    add_action( 'wp', function () {
    	bp_core_remove_subnav_item( 'profile', 'public' );
    } );
    

    Please do note that it will break access to user’s profile view as the ‘public’ is the default sub nav for profile.
    Also, here is a slightly better version to avoid fatal errors when BP is disabled.

    
    add_action( 'wp', function () {
    	if ( function_exists( 'bp_core_remove_subnav_item' ) ) {
    		bp_core_remove_subnav_item( 'profile', 'public' );
    	}
    } );
    
    

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49030

    Hi Brajesh, I’m sorry, but all solutions breaks my site. Clicking on a profile, directs to the frontpage.

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #49037

    Hi Carsten,
    That’s exactly what I mentioned in my previous reply.

    You can not remove a default sub nav without forcing another default.
    ‘public’ is the default profile sub nav and you are removing it causing 404. If you are getting redirected to somewhere else, you may have a 404 redirection enabled.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #49038

    Hi Brajesh, sorry for not perceiving this in your reply. So the conclusion is, that it is not possible to remove this tab.

    It is a bit redundant on other profiles, and does nothing good for the design with two profile tabs on top of each other. I guess I can hide it with css then.

    https://imgur.com/Emijrvf

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #49047

    Hi Carsten,
    No issues.

    It is possible to remove tabs if you are able to provide a substitute default tab.

    Also, It seems that in your use case, all you need is to hide the sub tab markup and no the actual content. I will suggest using css for that purpose.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved