Search code examples
wordpressbuddypress

need to update buddy press topbar


i am new to word press and trying to modify Buddy Press top bar.

my current top bar is

enter image description here

i want to make user area top bar like

enter image description here

the basic difference is to put the login user image/aviator on left side of bar.

and also if possible remove visit link from right side.

Thanks


Solution

  • I suggest you start by creating a custom theme (or plugin if you prefer) that is a child theme of the bp-default theme. Follow the instructions here or here.

    From there you can remove the Visit menu like so:

    remove_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu',        100 );
    

    When it comes to the avatar, the easiest solution is probably to unregister BuddyPress default admin bar logo bp_adminbar_logo, create a replacement function to output the avatar, and finally register that function instead.

    remove_action( 'bp_adminbar_logo',  'bp_adminbar_logo' );
    
    function my_adminbar_logo() {
        echo '<a href="' . bp_core_get_userlink( bp_loggedin_user_id(), false, true ) . '">';
        bp_loggedin_user_avatar( 'type=thumb&width=40&height=40' );
        echo "</a>";
    }
    
    add_action( 'bp_adminbar_logo',  'my_adminbar_logo' );
    

    There, just add some CSS and you're done :)