get_avatar not showing the loggedin users right avatar after comments

Discussion in 'WordPress' started by vgpap, Apr 16, 2012.

  1. #1
    I use the following code to display logged in users avatar and some other staff.
    if ( is_user_logged_in() ) {
    get_currentuserinfo();
    global $current_user;
    echo $user_id = $current_user->ID;

    echo '<div class="avatar">';
    echo get_avatar( $user_id, 32 );
    echo "</div>";
    }

    Eveything works fine.
    When before this thing i display comments, the avartar of current logged in user is wrong, its one of the comment author avatar.
    I echo the $user_id = $current_user->ID and is the right one but echo get_avatar( $user_id, 32 ) returns other.
    Any idea?
    Thanks.

     
    vgpap, Apr 16, 2012 IP