How to re-order Messages subnav items (tabs)
-
I was looking for a simple way to re-order subnav items. In my case, on the Messages page. I did a lot of searching came up short on a simple definitive answer that did not hack the core. I was able to finally piece meal the answer together from old threads and thought it might be helpful to have the solution in a single place, so here goes.
It’s basically the same technique as re-ordering the main nav items, but just one level deeper. I created this function and added it to my functions.php (really my custom plug-in in my case, but you get the idea).
function add_reorder_messages_subnav_tab() { global $bp; //reorder messages tabs $bp->bp_options_nav['messages']['compose']['position'] = 10; $bp->bp_options_nav['messages']['inbox']['position'] = 11; $bp->bp_options_nav['messages']['starred']['position'] = 12; } add_action( 'bp_setup_nav', 'add_reorder_messages_subnav_tab', 100 );
You just need to replace the
messages
part with the parent nav you want to work in, saysettings
.If you need to see the default order positions before you reorder them just dump the parent item like:
var_dump($bp->bp_options_nav['messages']);
Hope this helps.
-
Oh, sorry. I totally missed that. We’ll guess this still works for older versions. Thanks.
Just so this is complete. Here’s the code updated for BuddyPress 2.6 or later.
function add_settings_subnav_tab() { //reorder messages tabs buddypress()->members->nav->edit_nav( array( 'position' => 10, ), 'compose', 'messages' ); buddypress()->members->nav->edit_nav( array( 'position' => 11, ), 'inbox', 'messages' ); buddypress()->members->nav->edit_nav( array( 'position' => 12, ), 'sentbox', 'messages' ); buddypress()->members->nav->edit_nav( array( 'position' => 20, ), 'starred', 'messages' ); } add_action( 'bp_setup_nav', 'add_settings_subnav_tab', 100 );
Gracias seƱor ! I changed the topic title by adding “Messages”, as your snippet related specifically to this component.
- You must be logged in to reply to this topic.