I used this to try and add a link in the adminbar drop down menu. It worked, but the link is blank. I want it to say “Username”, but I don’t know where to put it lol.
/**
* add change username to adminbar
*/
function buddydev_update_personal_activity_in_admin_bar3() {
global $wp_admin_bar;if ( ! is_user_logged_in() ) {
return ;
}// Update personal activity Url for the logged in user
$wp_admin_bar->add_menu( array(
‘parent’ => ‘my-account-settings’,
‘id’ => ‘change-username’,
‘href’ => bp_loggedin_user_domain() . ‘settings/change-username/’,
) );
}
add_action( ‘bp_activity_setup_admin_bar’, ‘buddydev_update_personal_activity_in_admin_bar3’, 100 );Hi Chris,
you will need to pass title like this/** * add change username to adminbar */ function buddydev_update_personal_activity_in_admin_bar3() { global $wp_admin_bar; if ( ! is_user_logged_in() ) { return; } // Update personal activity Url for the logged in user $wp_admin_bar->add_menu( array( 'parent' => 'my-account-settings', 'id' => 'change-username', 'title' => 'Username', 'href' => bp_loggedin_user_domain() . 'settings/change-username/', ) ); } add_action( 'bp_activity_setup_admin_bar', 'buddydev_update_personal_activity_in_admin_bar3', 100 );
Hope that helps.
Regards
Brajeshahhhh, thanks a lot! Is there a way to change the order on the menu? By default it’s appearing above all other items.
Hi Chris,
The WordPress admibar does not allow specifying the priority. The solution is to delay the adding of menu item.You can change the action hook to this
add_action( 'wp_before_admin_bar_render', 'buddydev_update_personal_activity_in_admin_bar3', 100 );
and it will add at the bottom of the settings menu.
You must be logged in to reply to this topic.