WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Display name of logged user

[Resolved] Display name of logged user

  • Please, how to display in my header the name of the logged user in my header? (eg.: My name is webmaster, and I’d like to see Webmaster in the header of my index page)
    Thank you very much

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator cubecolour

    @numeeja

    Put this in your header.php were you want it to appear

    <?php global $current_user;
          get_currentuserinfo();
          echo 'You are logged in as: ' . $current_user->user_login;
    ?>

    It works fine, but one comment. Is it possible that the phrase: ‘You are logged in as: ‘ would appear only if the users are logged in?
    Maybe an If.. loop?
    Thanks

    Moderator cubecolour

    @numeeja

    Yes the code I put in the post above is appropriate for a private blog
    You could flesh it out like this for a public-facing one:

    <?php
    if ( is_user_logged_in() ) {
        global $current_user;
          get_currentuserinfo();
          echo 'You are logged in as: ' . $current_user->user_login;
    } else {
        echo 'you are not logged on';
    };
    ?>

    Working Fine!!!
    thank you very much numeeja!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Display name of logged user’ is closed to new replies.