Skip to content

Instantly share code, notes, and snippets.

@zamoose
Created March 12, 2012 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zamoose/2022736 to your computer and use it in GitHub Desktop.
Save zamoose/2022736 to your computer and use it in GitHub Desktop.
BP reordering
<?php
/**
* This function rearranges BuddyPress navigation elements.
*/
function npat_alter_group_options(){
global $bp;
if(NPAT_DEBUG) echo '<pre>';
$slug = $bp->groups->current_group->slug;
$nav_array = $bp->bp_options_nav;
$nav_array[$slug]["forum"]["position"] = 10;
$nav_array[$slug]["forum"]["name"] = "Group Forum";
$nav_array[$slug]["home"]["position"] = 20;
$nav_array[$slug]["home"]["name"] = "Activity";
$nav_array[$slug]["admin"]["position"] = 30;
$bp->bp_options_nav = $nav_array;
if(NPAT_DEBUG){
var_dump($bp);
echo '</pre>';
}
//bp_core_remove_subnav_item($bp->groups->current_group->slug, "" );
}
add_action( 'bp_init', 'npat_alter_group_options', 999 );
@boonebgorges
Copy link

Yes, I think this is fine. Unfortunately, at the moment, there's no way to do this with BP functions - though allowing modification of existing items using bp_core_new_subnav_item() is a nice idea for future enhancement.

The only suggestion I would make is that you should hook to 'bp_setup_nav' instead of 'bp_init', so that your changes have been made before the rest of BP loads. (Though it's very unlikely that you will experience any problems related to this.)

@zamoose
Copy link
Author

zamoose commented Mar 12, 2012

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment