Enhancing My Account Menu with BuddyPress in the adminbar
If you have WordPress adminbar enabled, with BuddyPress, you get a nice dropdown menu for the current logged in user. The problem with that menu is all the 3 links as shown in the image below, points to edit profile page.
 Hans asked me on our forum on how to improve it.
Hans asked me on our forum on how to improve it.
Here is our goal for this tutorial:-
- Howday, Username should link to user default page( user activity or whatever default component you have enabled)
- The User avatar and name(marked as 2) should go to the user profile page( username/profile)
- Edit My Profile link should remain as it is.
Well, Here is the code that you can put in your bp-custom.php or your theme's functions.php and It will work.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function buddydev_update_myaccount_links( $wp_admin_bar ) {     if ( ! is_user_logged_in() ) {         return ;     }     $profile_url = bp_loggedin_user_domain();     $wp_admin_bar->add_menu( array(         'id'        => 'my-account',         'href'      => $profile_url     ) );     $wp_admin_bar->add_menu( array(         'id'     => 'user-info',         'href'   => user_trailingslashit( $profile_url . BP_XPROFILE_SLUG ),     ) ); } add_action( 'admin_bar_menu', 'buddydev_update_myaccount_links', 100 ); | 
And if you want, you ma modify it as you want. I hope it gives you a starting point 🙂