Customize profile and group menus in BuddyPress

bp-menu-tweaking

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:

http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/customizing-buddypress-profile-page-default-tab-and-item-nav-order/

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`

http://pastebin.com/eTNKwgCR

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:

http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/changing-group-tab-display-defaults/#post-55449

  1. Nigel says:

    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!

  2. Siva says:

    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.

  3. dains says:

    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.

  4. Avatar of svenl77

    svenl77 says:

    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

    • lukas says:

      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.

  5. Don says:

    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

  6. Mike says:

    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?

  7. Avatar of nosy

    nosy says:

    @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?

  8. Alfredo says:

    @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?

    • Avatar of konrads

      konrads says:

      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

  9. Grace says:

    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

  10. Grace says:

    * 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!

  11. Sophie says:

    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

  12. Avatar of konrads

    konrads says:

    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

  13. jamalelomri says:

    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?

  14. Towfiq I. says:

    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?

  15. Towfiq I. says:

    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?

  16. David says:

    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.

    • Ashton Ward says:

      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

    • Larry says:

      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’);
      ?>

  17. Simon says:

    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’ );

  18. Pete says:

    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.

  19. Avatar of dmichelle

    dmichelle says:

    I tried and none of this worked for me. I’m not a developer. Looks like this information could be out of date?

  20. omdev says:

    how can i merge two profile group fields to one tab in edit profile tab in buddypress (i have a two profile group one is base and second is custom when i goes to my edit profile page it shows me two button one is base and second is custom i do not want it separately i want to merge their fields in single tab is it possible?)

  21. Avatar of svenl77

    svenl77 says:

    Hi @All,

    I see its time to write a update on this topic, I will update the article to support the newest version soon. Just added it to my todo list for the next days.

    Thanks for all the feedback ;-)

  22. Shaun Ramkelawon says:

    Hi, thanks for the excellent information, I was wondering if anybody knew how to remove the member count on the ‘Members’ Tab. Currently it shows something like this ‘Members (3)’ – or just ‘Members 3′. I want to remove the number count completely so that it just says ‘Members’. Please can someone help, been searching all over the place to no avail.

    Many thanks
    Shaun

    • Avatar of themekraft

      themekraft says:

      …simply via theme options in the Custom Community Theme:

      Profiles:
      go to Theme Settings > Profile > Profile Menu Order

      Groups:
      go to Theme Settings > Groups > Groups Menu Order

      ;)

  23. Pingback: Reordering Buddy Press profile navigation | question code
  24. Avatar of niangari

    niangari says:

    Hi everybody! Ok, after 10 hours of research and trying, I surrender and ask to people who know more than me.

    I’m trying to change the default tab “home” of each buddypress groups for the “forum”, so I can Hide or delete the “home” tab and only use the forum.

    I’ve tried hundreds of different codes I’ve found on diferent blogs but no one does ANYTHING in the way the tabs are shown or oppened in the groups.

    The last one I tried is this one (the simpliest one) http://screencast.com/t/tJE8UFQy7

    There is also the root in which I created the bp-custom.php file.

    I can’t think anything. Please could anybody help me with this?

    Thank you all!

  25. Avatar of svenl77

    svenl77 says:

    Hi @niangari,

    thank you for your comment and sorry for the late reply.

    At this time you need php knowledge.

    you need to create a static front.php. Maybe this article helps you.
    http://bp-tricks.com/featured/creating-a-custom-front-page-for-your-buddypress-groups/

    We have created a feature request and will add 2 new options for the groups and profil manipulation in the next version.

  26. Amal says:

    Hi svenl77,

    Thank you for this useful article. I want to rename “Change Avatar” tab in profile to “Change Photo”, do you know how I can do this?

    Thanks in advance
    Hope

  27. Jeff says:

    Hello ! Thanks for this great article and discussion. Any idea to make work the code to set the forum nav item as the default nav item in groups in the latest version of buddypress ? I said that I have a french version, is there perhaps a problem ? Thanks for helping me !

    • Avatar of konrads

      konrads says:

      hi Jeff,

      you can change order but not which tab is the actual starting tab when you open a profile for example..

      I made a new ticket on github for adding these features for one of the next updates, see link to github here:
      https://github.com/Themekraft/Custom-Community/issues/79

      konrad

  28. Thorsten says:

    Hi There,

    Thanks for the great explanation. I need to change the sub menu item ‘friends’ within ‘activity’ to the first position and make it active. Any idea how to solve this?

    Many thanks in advance.

    Tee

    • Tecca says:

      This still works. Make sure you edit the above because the php isn’t displaying properly. For example:

      `/*
      * Change order of user profile tabs
      */
      function bbg_change_profile_tab_order() {
      global $bp;

      $bp->bp_nav[\'profile\'][\'position\'] = 10;
      $bp->bp_nav[\'activity\'][\'position\'] = 20;
      $bp->bp_nav[\'achievements\'][\'position\'] = 30;
      $bp->bp_nav[\'friends\'][\'position\'] = 40;
      $bp->bp_nav[\'messages\'][\'position\'] = 50;
      $bp->bp_nav[\'forums\'][\'position\'] = 60;
      $bp->bp_nav[\'settings\'][\'position\'] = 70;
      }
      add_action( ‘bp_setup_nav’, ‘bbg_change_profile_tab_order’, 999 );`

  29. mmoore5553 says:

    anyone know how to have it go back one directory. See my question here http://wordpress.stackexchange.com/questions/137991/buddypress-slug-issues

  30. gautamarya says:

    Before sometime I was struggling to get my work done.

    Thanks to your tutorial. I just not solve my problems but also gives me an understanding of how BuddyPress works.

  31. Meagan O'Brien says:

    This didn’t work anymore for me. Probably too many BP/WP updates. On BP 2.0.1 right now. Here is solution to paste into your bp-custom.php:

    function bbg_change_profile_tab_order() {
    global $bp;

    $bp->bp_nav[\'profile\'][\'position\'] = 10;
    $bp->bp_nav[\'activity\'][\'position\'] = 20;
    $bp->bp_nav[\'groups\'][\'position\'] = 30;
    $bp->bp_nav[\'settings\'][\'position\'] = 40;
    }
    add_action(‘bp_setup_nav’, ‘bbg_change_profile_tab_order’, 999 );

    found on the comments section of this post: http://bp-tricks.com/snippets/code/arrange-group-profile-navigation-menu/
    thx.

Leave a Reply

Your email address will not be published. Required fields are marked *

287 Spambots Blocked by Simple Comments

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=""> <strike> <strong>