Re: How to Remove and Add Items in “bp_get_displayed_user_nav”
just to add to this discussion, concerning what hook to link it to…this is what works for me. i didnt have luck with bp_setup_nav for some reason. i dont recall where i got this example, but think its bp-xprofile.php itself. this worked in both theme>functions.php and in my own mmc_functions.php which i “require()” in functions.php
just to add a hint of background, we are moving these two items to the ‘settings’ tab from the profile tab. the removing is trivial, the adding is trivial, the getting all the right functions/themes/forms called, not so much. but its done and it works.
here is the code for removing sub-tabs — aka options:
`
//removes in a structural way.. no change to bp-xprofile.php
function mmc_bpsetupnav_removefromprofile(){
global $bp;
if ( $bp->current_component == $bp->profile->slug ) {
bp_core_remove_subnav_item($bp->profile->slug, ‘edit’);
bp_core_remove_subnav_item($bp->profile->slug, ‘change-avatar’);
}//end if
}//end function
add_action( ‘wp’, ‘mmc_bpsetupnav_removefromprofile’, 2 );
`
here is my code for adding them to the settings tab
`
////////////////////////////////////////////////////////////
////// functions for moving to Settings tab the editprofile/change avatar sub-tabs
function mmc_bpsetupnav_forsettings(){
global $bp;
if ( $bp->current_component == $bp->settings->slug ) {
//define ( ‘BP_XPROFILE_SLUG’, ‘settings’ );//didnt have desirable effects. left her for documentation
//this is essentially a clone of xprofile-settings.php, but with tweaks to change BP_XPROFILE_SLUG references tp BP_SETTINGS_SLUG
//that way didnt change any core files, and moved it out of the upgrade stream
require_once( WP_PLUGIN_DIR.’/mmc_misc/functions_xprof_settings_mmc.php’);
$profile_link = $bp->loggedin_user->domain . $bp->profile->slug . ‘/’;
$settings_link = $bp->loggedin_user->domain . $bp->settings->slug . ‘/’;
//EDIT PROFILE
bp_core_new_subnav_item( array(
‘name’ => __( ‘Edit Profile’, ‘buddypress’ ),
‘slug’ => ‘edit’,
‘parent_url’ => $settings_link,
//’parent_slug’ => $bp->profile->slug, //left for documentation
‘parent_slug’ => $bp->settings->slug,
‘screen_function’ => ‘xprofile_screen_edit_profile_mmc’,
‘position’ => 50, //magic number based on current items already there in SETTINGS tab
‘user_has_access’ => bp_is_my_profile() //ADDED, NOT IN ORIGINAL WHEN IN BP-XPROFILE.PHP
) );
//CHANGE AVATAR
bp_core_new_subnav_item( array(
‘name’ => __( ‘Change Avatar’, ‘buddypress’ ),
‘slug’ => ‘change-avatar’,
‘parent_url’ => $settings_link,
//’parent_slug’ => $bp->profile->slug, //left for documentation
‘parent_slug’ => $bp->settings->slug,
‘screen_function’ => ‘xprofile_screen_change_avatar_mmc’,
‘position’ => 60, //magic number based on current items already there in SETTINGS tab
‘user_has_access’ => bp_is_my_profile() //ADDED, NOT IN ORIGINAL WHEN IN BP-XPROFILE.PHP
) );
}//end if
}//end function
add_action( ‘wp’, ‘mmc_bpsetupnav_forsettings’, 2 );
add_action( ‘admin_menu’, ‘mmc_bpsetupnav_forsettings’, 2 );
`
note the TWO add-actions at the end. also taken from example at bp-xprofile.php. why this and not bp_setup_nav.. i dont know!
ggod luck
mario