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?
<?php function blah_blah () {
global $user_identity;
printf($user_identity);
} ?>
bschwarting
Member
Posted 18 years ago #
i guess the function is really my question then...
lunabyte
Member
Posted 18 years ago #
if ( is_user_logged_in() ) {
global $current_user, $blog_id;
$username = $current_user->user_login;
} else {
$username = "Guest";
}
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 ?>