Customize profile and group menus in BuddyPress
February 16, 2011 in How To by svenl77
This is a short article about menu tweaking in profiles and groups.
It took me a while to find all the answers, that’s why I bring all together here, so you do not need to search again.
Starting with the profiles
1. Change the menu order in the profile
If you like to change the menu order in your profile pages, you will need to create a bp-custom.php in your plugin directory. Just create the new file inside the folder wp-content/plugins.
Add the following function to the bp-custom.php:
`pre type=”php”`
function bbg_change_profile_tab_order() {
global $bp;
$bp->bp_nav['profile']['position'] = 10;
$bp->bp_nav['activity']['position'] = 20;
$bp->bp_nav['friends']['position'] = 30;
$bp->bp_nav['groups']['position'] = 40;
$bp->bp_nav['blogs']['position'] = 50;
$bp->bp_nav['messages']['position'] = 60;
$bp->bp_nav['settings']['position'] = 70;
}
add_action( ’bp_setup_nav’, ’bbg_change_profile_tab_order’, 999 );
`/pre`
The number is for the position of the menu. If you have plugins installed, who add their own menu item into your profile nav, use the slug of the component to manipulate the position.
For example if you have events or a gallery nav item, it would be something like this:
`pre type=”php”`
$bp->bp_nav['events']['position'] = 40;
$bp->bp_nav['gallery']['position'] = 50;
`/pre`
2. Rename a menu item
Add the following line to the function and change the activity to what ever you want to rename:
`pre type=”php”`
$bp->bp_nav['activity']['name'] = ‘wall’;
`/pre`
3. Remove a menu item
If you want to remove a nav item, add this line to the function and change activity to whatever you want to remove:
`pre type=”php”`
$bp->bp_nav['activity'] = false;
`/pre`
Have a look at the forum post where I got the most info from:
Now we go to the groups
1. Change the menu order in groups
If you like to change the menu order in your profile pages, you will need to create a bp-custom.php in your plugin directory. If you already have a bp-custom.php, just add the function at the end before the “?>”
`pre type=”php”`
function my_bp_groups_forum_first_tab() {
global $bp;
$bp->bp_options_nav['groups']['home']['position'] = ’50′;
}
add_action(‘wp’, ’my_bp_groups_forum_first_tab’);
`/pre`
This function works exactly the same way, like the profile function works. The number is the position.
In this function we just move the home item. Adding more lines like in the profile function above depends on what nav items you have in your group.
2. Set the forum nav item as the default nav item in groups
To make the forum your home tab of the group, paste the following in /wp-content/plugins/bp-custom.php:
`pre type=”php”`
function redirect_to_forum() {
global $bp;
$path = clean_url( $_SERVER['REQUEST_URI'] );
$path = apply_filters( ’bp_uri’, $path );
if ( bp_is_group_home() && strpos( $path, $bp->bp_options_nav['groups']['home']['slug'] ) === false )
bp_core_redirect( $path . $bp->bp_options_nav['groups']['forum']['slug'] . ’/' );
}
add_action( ’wp’, ’redirect_to_forum’ );
`/pre`
http://pastebin.com/j3n17CVe (you’ll probably need to tweak the code for BP subdomain installs!)
3. Rename a nav item
If you want to rename a nav item, copy this line to the my_bp_groups_forum_first_tab function. This example will change “Home” to “Something”.
`pre type=”php”`
$bp->bp_options_nav['groups']['home']['name'] = ‘Something’;
`/pre`
4. Remove a nav item
Add this line to the my_bp_groups_forum_first_tab function to remove the home item. Change the home to your needs:
`pre type=”php”`
$bp->bp_options_nav['groups']['home'] = false;
`/pre`
Have a look at the forum post where I got the most info from:

Excellent article. Found everything I needed right in one place. THANKS SO MUCH!
Hi Sven
a lot of really helpful stuff here all in one place, thanks.
As buddypress menu guru, maybe you know if something I’m trying to do is even possible: from elsewhere can you link directly to a sub-menu. For example, somewhere on my site I want a link to go directly to the forum page, somewhere else a link to go directly to the members list etc. So I’m not talking about hard-coding a new home page, for example. Any ideas?
Thanks!
Thanks for the article. However I am not a techie. Yet, I am trying hard to understand. I am looking to create custom fields for BP Groups as like as in BP user profiles. For instance, I wish to create fields such as Name, Location, Postal Code to my Groups. Admins should be able to edit it. Please guide me to achieve these things. Thanks in advance.
Hi again Sven
I realised the answer to my own question, thanks anyway…
Very nice Sven, thank you very much for doing this! You’ve helped overcome two problems I needed to solve.
I notice that the function for the profile tab groups is bp_nav while groups is bp_options_nav. Anyone know of a list of these for all of the tab groups in BP? We really should be able to customize any tab group in BP, and I think all that’s missing is the references for the functions.
Update: I have created tow new functions for handling the menu tap order in groups and profiles.
Its much easier as explained in this article
Have a look here https://gist.github.com/970170
Please how can I Add the component slugs coma separated in the order you like to have the nav menu tabs? Can you give me an example.
THANK YOU for taking the time to post this, just want I needed!
Brilliant! I have been trying to figure out how to make changes to the groups and this is nice and simple and exactly what I was looking for. Thanks
Is there a way to add a class and title attribute to a group or profile item using this method? I would like to add a javascript popup to my menu items because I’ve changed them to icons similar to Google Plus’s menu at the top. Any ideas?
@Mike: $bp->bp_options_nav['groups']['home']['css_id']
@svenl77 Great article! One question: Set the forum nav item as the default nav item in groups works fine, but what’s about the settings? Users are able to disable the forum. Then it doesn’t work anymore. What’s to do to remove the forum function from the settings?
@svenl77 Thanks for the article! I’m using the budyboss theme and the function added an extra slot but there’s nothing in the slot. just a space between two lines. How and what do i edit to change this?
Hi there, nice article!
I wonder if you found a way to add a menu tab to the profile page?
I know you can do this for group profiles right now:
http://themekraft.com/buddypress-docs-add-doc-to-nav/
but also have a deeper look in the BP plugin repository, maybe you find a plugin for exactly your needs. otherwise to would have to step into the code…
konrad
Thanks!
Little confused.. what should that bp-custom.php entirely?
Does it need the rest of the page formatting too? or just open php – put that snippet in there – and that’s it?
: / sorry – total noob with editing in Buddypress
* for me the problem was that copy/pasting from the post resulted in curly quotes that i had not noticed
replaced them and BAM . thank you!
hey guys, this is probably a really stupid question, but how do I change the layout of the home page? I want just simple text on it!! thanks
have a look in the FAQ for custom homepage:
http://themekraft.com/faq/making-a-custom-homepage/
checkout the support forums for support: http://themekraft.com/forums/
have a nice day, konrad
Awesome, thorough article. Huge help – thanks and keep it up!
This is great, thanks for the tip! However, when I remove a tab I end up with a blank tab at position 0. Any ideas?
Jackie, did you ever sort out your blank tab problem? I am having the same issue.
Yep – me too. I get:
When I remove a field..
helo i wana costomise my profile buddypress for add a menu for visiter of my profil to post a message or comments.
can you help me?
Thanks….Great!
Thanks for sharing this tuts it will be helpful for my buddypress site
Awesome Share! I am having to add css class to the menu item though. I added this to my bp-custom.php with no avail:
function bbg_change_profile_css() {
global $bp;
$bp->bp_options_nav['profile']['css_id'];
}
add_action( ‘bp_setup_nav’, ‘bbg_change_profile_css’, 999 );
Any help?
OK. I tried this and it works, but it changes the id, but I wanted to add class, not id:
function bbg_change_profile_css() {
global $bp;
$bp->bp_nav['friends']['css_id'] = ‘new_css’;
}
add_action( ‘bp_setup_nav’, ‘bbg_change_profile_css’, 999 );
Do you know how to add class to the menu item?
Hi great article! Taking this concept one step further can you delete/rename subnav Profile Menu items in the same way?
$bp->bp_nav['profile']['public'] = false;?
(tried with no avail) Any helpful advice on this would be helpful.
Thanks in advance!
This works: $bp->bp_options_nav['activity']['all-activity']['name'] = ‘Everyone’;
Hope that helps
I can not get this to work at all.
the redirect does nothing.
I’m having the same issue, I created this topic in the WordPress support forums looking for guidance but there’s been no replies so far: http://wordpress.org/support/topic/buddypress-groups-optimization
Code needs to be updated for newer version of buddypress and wordpress. Try a version of this:
bp_options_nav[$bp->groups->current_group->slug]['home']['slug'] ) === false ) {
if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == ‘public’) {
bp_core_redirect( $path . ‘forum/’ );
}
}
}
function move_group_activity_tab() {
global $bp;
if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) {
$bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = ’98′;
$bp->bp_options_nav[$bp->groups->current_group->slug]['home']['name'] = ‘Something’;
}
}
add_action(‘bp_init’, ‘redirect_group_home’ );
add_action(‘bp_init’, ‘move_group_activity_tab’);
?>
Just changing the action call seemed to work for me upgrading to 1.5
function redirect_to_forum() {
global $bp;
$path = clean_url( $_SERVER['REQUEST_URI'] );
$path = apply_filters( ‘bp_uri’, $path );
if ( bp_is_group_home() && strpos( $path, $bp->bp_options_nav['groups']['home']['slug'] ) === false )
bp_core_redirect( $path . $bp->bp_options_nav['groups']['forum']['slug'] . ‘forum/’ );
}
add_action( ‘bp_init’, ‘redirect_to_forum’ );
Does anyone know how to remove the “All Groups” or “My Groups” tab from the default BP theme when viewing Groups? To clarify, when you go to the groups page you have the tabs “All Groups” and “My Groups” which are both populated with AJAX calls. I have a site that is 100% private with only hidden groups. I want users to only see a list of their groups, hence the “My Groups” tab. However, lots of navigation and what have you defaults to the “All Groups.” I would like to either remove the “My Groups” and let it default to all, or remove the “All Groups” and let it default to “My Groups.” Leaving the “All Groups” is an option since all of my groups are hidden anyway.