BuddyDev

Reordering BuddyPress User Profile tabs

BuddyPress 2.6.0 introduced simpler ways to organize nav items. If you are looking for ways to reorder, It is very simple.

Before we dive into code, some basics first.

BuddyPress uses numeric position as a way to sort the nav items. The nav items are ordered in ascending order(lower values come first). We can use the edit_nav() method of the BP_Core_Nav class to update the position.

To update the position of a user profile nav item,  you can use the following code

Please make sure to change the $nav_slug with the actual nav item slug and the $new_position with a number.

In the function, the first argument is the details we want to update and the second argument is the slug of the nav item.

Example:-

Here is a complete example of reorganizing multiple profile tabs. It is not necessary to reorder all tabs, you may only order the relevant tabs for you.

And the result:-

Please update the position as you wish. You should put the in your bp-custom.php.

Have fun!

4 Responses to Reordering BuddyPress User Profile tabs

  • People could also use the free BuddyPress Reorder Tabs plugin from BuddyBoss. Works just fine, and can also reorder tabs for groups.

    • Hi Nathan,
      Thank you for the comment.
      The BuddyBoss Reorder Tabs plugin is buggy. It overwrites all tabs. I am not sure if it works properly now. But I remember it causing me a headache as it almost overtook the tabs and some new custom tabs disappeared because of it.

      Also, the plugin is bulky and I don’t see any point in using the plugin if you are a developer. The code is aimed at developer.
      As for groups, you can adapt the same code for groups, all you need to change is buddypress()->members->nav to buddypress()->groups->nav;

  • Can you also do this to completely delete some of these tabs? Rather than hiding it via CSS?

    • Hi Graham,
      My apologies for the delayed reply.
      You can use the same action to delete a link. All you need to do is use this function

      and for sub navs

      Please make sure you don’t delete the default sub nav. It is problematic.

      Regards
      Brajesh

Leave a Reply

Are you looking for support?

Please ask support questions in BuddyDev Forum and help us serve you better. Please use comment for general discussion/feature suggestions.

Your email address will not be published. All the fields marked as * are required.

If you are posting code, please use <pre> { Your Code Block } </pre>. Example:- <pre> echo $name; </pre>

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


Subscribe