The MU forums have moved to WordPress.org

display username like in comments (5 posts)

  1. bschwarting
    Member
    Posted 18 years ago #

    just wanted to say that I've been lurking around the forums for a couple weeks with great success. almost all of my answers have come from searching. i can't seem to find this one though.

    i want to be able to display the username of who is logged in. i see it can be done by the comments page that shows "Logged in as admin. Logout ยป" i've looked at the code and experimented with no success. can someone assist?

  2. dsader
    Member
    Posted 18 years ago #

    <?php function blah_blah () {
    global $user_identity;
    printf($user_identity);
    } ?>
  3. bschwarting
    Member
    Posted 18 years ago #

    i guess the function is really my question then...

  4. lunabyte
    Member
    Posted 18 years ago #

    if ( is_user_logged_in() ) {
    	global $current_user, $blog_id;
    	$username = $current_user->user_login;
    } else {
    	$username = "Guest";
    }
  5. bschwarting
    Member
    Posted 18 years ago #

    awesome, that worked great. thanks!

    for those as new as me :), i just added this to display it.

    <?php echo $username ?>

About this Topic

  • Started 18 years ago by bschwarting
  • Latest reply from bschwarting