Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Link "Howdy" to Wall

  • @skyrie

    Participant

    As of now when I click on the “Howdy, Username” box it takes me to /members/username/profile/edit/ which isn’t very good. Most users only edit their profile a few times, the rest of the time they want to view their wall page. Does anyone know how I can change this so it just takes me to /members/username/?

Viewing 2 replies - 1 through 2 (of 2 total)
  • @djpaul

    Keymaster

    You’re going to have to write some code: something like this should point you in the right direction http://www.wpbeginner.com/wp-tutorials/how-to-change-the-howdy-text-in-wordpress-3-3-admin-bar/

    @jreeve

    Participant

    @skyrie, You’ve probably already figured this out by now, but in case anyone else wants to know how to do this, you can put this code in your functions.php:

    function my_admin_bar_change_howdy_target( $wp_admin_bar ) {
            $user_id = get_current_user_id();
            $current_user = wp_get_current_user();
            $profile_url = get_edit_profile_url( $user_id );
            if (substr($profile_url, -5) == 'edit/') {
                    $profile_url = substr($profile_url, 0, -5);
            }
    
            if ( 0 != $user_id ) {
                    /* Add the "My Account" menu */
                    $avatar = get_avatar( $user_id, 28 );
                    $howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name );
                    $class = empty( $avatar ) ? '' : 'with-avatar';
    
                    $wp_admin_bar->add_menu( array(
                            'id' => 'my-account',
                            'parent' => 'top-secondary',
                            'title' => $howdy . $avatar,
                            'href' => $profile_url,
                            'meta' => array(
                                    'class' => $class,
                            ),
                    ) );
    
            }
    }
    add_action( 'admin_bar_menu', 'my_admin_bar_change_howdy_target', 11 );

    Also I’d love to hear suggestions for better ways of doing this, in case anyone has any.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Link "Howdy" to Wall’ is closed to new replies.
Skip to toolbar