BuddyDev

Search

[Resolved] How to modify wp-admin-bar-my-account?

  • Participant
    Level: Enlightened
    Posts: 134
    HansRuedi Keller on #2263

    Hi Brajesh,

    I would like to modify the admin-bar quicklinks. The first one (Howdy, username) should go to /members/username (facebook-like to that users activity), the second one next to the avatar (display and username) to /members/username/profile (other words NOT to /edit). That way only the third own called “Edit profile” will go to /edit. That really would make sense for me…

    Do you have time to provide code for bp-custom.php to change the behavior of these first two quicklinks in the toolbar?

    Thanks, Hans

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #2264

    Hi Hans,
    Thank you for asking.
    can you please give it a try and let me know if it works as expected?

    
    
    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'   => $profile_url,
    		
    	) );
    	
    	
    }
    add_action( 'admin_bar_menu', 'buddydev_update_myaccount_links', 100 );
    
    

    Looking forward to hear your feedback.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 134
    HansRuedi Keller on #2265

    Hi Brajesh,

    Thanks for your fast reply. The first one (Howdy, username) is perfect. But the second link, the one right side of the avatar is now also going to users activity but should link to /members/username/profile/

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #2266

    Hi Hans,
    I am sorry, I should have read the requirement carefully. Here is the updated code

    
    
    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 );
    

    Please do let me know how it goes? The avatar and the name will point to the profile now.

  • Participant
    Level: Enlightened
    Posts: 134
    HansRuedi Keller on #2267

    Absolutely perfect. If somebody would ask me, I would say that should be BuddyPress default…

    Thanks, Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #2268

    You are welcome Hans. I too believe that this should be by default. May be we should open a ticket for enhancement?

  • Participant
    Level: Enlightened
    Posts: 134
    HansRuedi Keller on #2269

    If you open the ticket it will definitely get some attention… 😉

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #2302

    I’m using this code. Thanks a lot!

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #2307

    Thank Christopher for taking time to reply. Appreciate it 🙂

    PS: I wrote a blog post yesterday to make t available for everyone. Thank you Hans for bringing it 🙂
    https://buddydev.com/buddypress/enhancing-my-account-menu-with-buddypress-in-the-adminbar/

  • Participant
    Level: Enlightened
    Posts: 134
    HansRuedi Keller on #2315

    Brajesh, did you already open a ticket?… 🙂

The topic ‘ [Resolved] How to modify wp-admin-bar-my-account?’ is closed to new replies.

This topic is: resolved