BuddyPress Profile: Change Default Nav Menu Tabs and Sub Items

Even for an adept WordPress developer, making changes in BuddyPress templates, the member components in particular, can return frustrating results. In this tutorial we will cover the basic management functions for the BuddPress Member Profiles, which include:

Modified BP Member Profile Menu
  1. BP Nav Functions
  2. Default BP Menu Items
  3. Customizing BP Profile Tabs
  4. Edit BP Profile Sub-Nav Items
  5. Adding/Removing BP Nav Menu Items

BuddyPress 1.7+ Member Profile Nav Functions

Like many other BP related code extensions, using the global $bp within our functions is essential. A function is required for the creating or changing of the BP profile's main menu items, and a separate one for the profile's sub-menu items. All these functions have to be queued in the bp_setup_nav action in the correct order, hence the function to create new sub-nav items for a custom main tab you create would have to run after the main tabs are created.

The Action: bp_setup_nav

The following functions will be added to the action bp_setup_nav, with a high priority, to assure that your function runs after all the important ones for the profile nav have finished:

// Default Usage:
add_action('bp_setup_nav', $function, $priority);

// Example:
add_action('bp_setup_nav', 'add_your_custom_tabs', 151);
add_action('bp_setup_nav', 'add_your_custom_subtabs', 152);

Default BuddyPress Profile Menu Items

Modifying the main BP profile navigation tabs requires little code, and can only be done to the tabs you activated in the BuddyPress settings to prevent errors. If all your BuddyPress default components are activated, you should have the following main items in your profile (if logged in as an administrator):

  1. Activity
  2. Profile
  3. Sites (if on a WP multisite network)
  4. Messages
  5. Friends
  6. Groups
  7. Settings
  8. Forums (if BBPress forums are integrated)

To modify each nav items position or name, you would access it by its slug, which you can determine by the url after /members/username/, but the default BP nav slugs are typically a lower-case version of its name. Here the default usage:

$bp->bp_nav[$slug][$data] = $value;

Change BuddyPress Profile Menu Positions & Names

The positioning of these menu items are determined by their position number, for example, the default position of Activity is 10 and that of Profile is 20. To change the default menu item positions, you can use a function similar to this:

function mb_profile_menu_tabs(){
global $bp;
$bp->bp_nav['activity']['position'] = 15;
$bp->bp_nav['messages']['position'] = 10;
}
add_action('bp_setup_nav', 'mb_profile_menu_tabs', 201);

The above code would replace the first tab from Activity to Members, and places Activity before Profile (because Profile has a position number of 20).

Changing BP Navigation Names

Similar to the above, changing the default BP profile tab names can be done by replacing the 'position' string, with 'name'. We added 3 new rows to the above function in this example:

function mb_profile_menu_tabs(){
global $bp;
$bp->bp_nav['activity']['position'] = 15;
$bp->bp_nav['messages']['position'] = 10;
$bp->bp_nav['messages']['name'] = 'Mail';
$bp->bp_nav['friends']['name'] = 'Contacts';
$bp->bp_nav['profile']['name'] = 'Account';
}
add_action('bp_setup_nav', 'mb_profile_menu_tabs', 201);

Edit BP Sub Nav Names & Positions

Rename BP Profile Subnav Item

Editing the BuddyPress sub-menu items relies on a similar structure as their parent items, the main tabs. The significant difference here is that instead of using the bp_nav object, we will need to use bp_options_nav to access theme. In addition, we require the subnav items parent slug:

Default Usage: $bp->bp_options_nav[$parent_slug][$slug][$data] = $value;

For example, if you intend to modify the 'Change Avatar' submenu item, under the 'Profile' tab, then you would use the parent slug profile and the target submenu item's slug, in this case change-avatar (Default BP submenu items may have their slug as an id, when viewing it in the source):

$bp->bp_options_nav['profile']['change-avatar']['name'] = 'Change Profile Picture';

Here, the final code snippet:

function mb_profile_menu_tabs(){
global $bp;
$bp->bp_nav['activity']['position'] = 15;
$bp->bp_nav['messages']['position'] = 10;
$bp->bp_nav['messages']['name'] = 'Mail';
$bp->bp_nav['friends']['name'] = 'Contacts';
$bp->bp_nav['profile']['name'] = 'Account';
$bp->bp_options_nav['profile']['change-avatar']['name'] = 'Change Profile Picture';
}
add_action('bp_setup_nav', 'mb_profile_menu_tabs', 201);

As usual, please feel free to point out mistakes or improvements.

I'm a developer at Maximus Business.
  • raul
    i was wondering in which file do i add this code to? Thanks!

    Said on Sep 16, 2013 by raul - Reply
    • Maximilian
      You can add the above code to your functions.php file, which is in your themes root folder.

      Said on Sep 17, 2013 by Maximilian - Reply
      • Paul
        I'm sorry, but I can't seem to locate the functions you're referring to. You say that they are in the functions.php file in my themes root folder, but I don't see it. It's not in the functions.php file in the theme that I am using (One Community) and it isn't in bp-core-functions.php either... Any ideas?

        Said on Aug 28, 2014 by Paul - Reply
  • kmiekio
    Very helpfull article. But I would like to ask how to remove some items out of this menu ?

    Said on Nov 13, 2013 by kmiekio - Reply
  • Kian
    Hi, I am developing a custom buddypress child theme. I need to remove the adminbar and add the my-account with avatar to the menu to the custom menu that I am creating. I am able to remove the admin bar using the following code: add_filter( 'show_admin_bar', '__return_false' ); in functions.php But I want the MyAccount drop-down menu in my custom menu, could you please help me how to go about this. Thanks Kiran

    Said on Nov 18, 2013 by Kian - Reply
  • Cory I
    This is great but I can not find anywhere how to change the menu for the activity page. Specifically renaming My Friends and My Groups just like in this post.

    Said on Feb 11, 2014 by Cory I - Reply
  • matthew
    Is there way when you add new menu item to not append members/mmoore5553/members i want to remove the members/mmoore5553 so it is just /members. I posted the question here also http://wordpress.stackexchange.com/questions/137991/buddypress-slug-issues

    Said on Mar 14, 2014 by matthew - Reply
  • Kris
    Thanks for the info. Is there a way to move a top level nav item to a sub item? For example, I have the follow plugin active. It then adds the Following and Followers menu items to the top nav. To clean that up, I would rather have those as sub menus under Friends. thanks

    Said on Mar 22, 2014 by Kris - Reply
  • Austin
    How do I add option nav items, such as edit profile, to the bp main nav? I have hard coded the links which works but I want it to be more dynamic. I am using the newest versions of wordpress and buddypress. Thanks in advance for your help. Austin

    Said on May 22, 2014 by Austin - Reply
  • Peter Netz Lassen
    Hi, Any chance you could show me how I remove the "HOME" link in the Navigation Today I have "Home" - "Forum" - "Members" I want to remove "Home" - It's useless for me I tried a few hundred things / codes in my bp-custom.php and functions.php with out luck I am running a 2.0.1 BP and a WP 3.9.1 (DK) here www.offerforum.dk Thanks Peter

    Said on Jun 17, 2014 by Peter Netz Lassen - Reply
  • Roman
    Is this still current? Can't seem to replicate the results.

    Said on Oct 6, 2014 by Roman - Reply
  • Michael Eisenwasser
    We created a free plugin to make this process simpler. Reorder profile and group tabs, and sub-tabs, and set the default tab. BuddyPress Reorder Tabs http://www.buddyboss.com/product/buddypress-reorder-tabs/ Youtube video walkthrough: https://www.youtube.com/watch?v=ldI2Qv5Q4To

    Said on Aug 2, 2015 by Michael Eisenwasser - Reply
  • chetan
    hey i had used this code its work in wall profile but buddyboss while at top tight corner menu still its show Blog rather than my text can u help i want change name Blog from every where to word Press Released or any thing i can share image but no option for upload here

    Said on Oct 19, 2016 by chetan - Reply
  • JCfromKC
    Thank you!

    Said on Jul 7, 2019 by JCfromKC - Reply

Leave a Reply

Please feel free to give us your feedback and comment below. Please keep in mind that comments are moderated. Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>