Created
March 12, 2012 15:38
-
-
Save zamoose/2022736 to your computer and use it in GitHub Desktop.
BP reordering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.)