• Hi there!

    I wonder how I can make WordPress show the username who’s currently logged in (on the front page for example).. I’ve tried it with <?php echo(” wp_user”); ?> but it only returns wp_user when I load the page…
    I’d be happy about any suggestions!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • here you go. i just created this code now (php is starting to look easier :P)


    <?php get_currentuserinfo();
    if ( $user_nickname<> "" ) { ?>
    <p class="credit">Welcome <?php echo $user_nickname ?>, To The Programmers Forum
    <?php } else { ?>
    <p class="credit">Welcome Guest, To The Programmers Forum
    <?php } ?>

    i put that in my index page, you can see it working at the top of the page at https://www.theprogrammersforum.com

    Thread Starter Ascendant

    (@ascendant)

    That’s great, i’m just implementing it for my site as well! Thanks a lot!!!

    I just tried using this, but no dice. Can this be called upon from out of the loop?

    It just shows the guest message, regardless if im logged in or not. I’m using wp 1.5.

    Got it:

    <?php global $user_nickname;
    get_currentuserinfo();
    if ( $user_nickname<> “” ) { ?>
    Welcome <?php echo $user_nickname ?>.
    <?php } else { ?>
    Welcome Guest<?php } ?>

    I was just wondering…what’s the filename where I paste this PHP code.
    Thanks in advance for any help.
    Vic
    https://www.zangla.com

    Vzangla, you can out the code in any of the files.
    Just wanted to thank Phillip. This worked great for me! Now unregistered guests get a message telling them to register. Just what I needed.

    Sorry for bumping this up, but this doesn’t work for me… Even if I login, it still shows as Guest.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display User Name on Front Page’ is closed to new replies.