WordPress.org

Ready to get started?Download WordPress

Forums

How to show the username of whos logged in? (8 posts)

  1. godofcomics
    Member
    Posted 6 years ago #

    Hello,

    I want to be able to implement this:

    Hello (person username here if he is logged in)!

    OR

    Hello Guest!

    "Guest" if the person is not logged in.

    How? I did so many searches, didn't find anything :(

  2. moshu
    Member
    Posted 6 years ago #

  3. krushinfo
    Member
    Posted 5 years ago #

    Is there anyway to show FIRSTNAME LASTNAME rather than username?

  4. krushinfo
    Member
    Posted 5 years ago #

    I managed to put the username in like this:

    <?php
    global $current_user;
    if ( isset($current_user) ) {
        echo $current_user->user_login;
    }
    ?>
  5. tationline
    Member
    Posted 5 years ago #

    Hello,

    I am a newbie and want to implement this function in my blog.
    I was hoping, that there was a plugin for that function, so that I do not have to modify files ... but I couldn't find any.

    In which file(s) do I have to add the above code?
    (I couldn't find a "how to" for this ...)

  6. Justin Tadlock
    Member
    Posted 5 years ago #

    In which file(s) do I have to add the above code?

    Where do you want it to go on your site?

  7. SuperMario290
    Member
    Posted 5 years ago #

    Hey, this is exactly what I needed. Thanks lot moshu and krushinfo for the link and code. :)

  8. clickforward
    Member
    Posted 5 years ago #

    Here is a nice example I came up with.

    <?php  if (is_user_logged_in()){
    global $current_user; get_currentuserinfo();
    echo('Welcome, ' . $current_user->user_firstname . ' | ');
    }
    else {
    echo "Welcome, Visitor | ";
    };
    ?>

    The user_firstname can be changed to a number of things. See: Function_Reference/wp_get_current_user

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags