WordPress.org

Ready to get started?Download WordPress

Forums

Login information (8 posts)

  1. metalvalley
    Member
    Posted 6 years ago #

    On my website http://www.klifix.eu I like to add the username in my header.

    I currently use this code:
    [code]<?php global $userdata; get_currentuserinfo();
    echo('Ingelogd als: ' . $userdata->user_login . "\n");
    ?>[/code]

    This only shows the username when logged in. But when not logged it showes nothing. I'd like to add the function to show the name 'guest' when a user is not logged in.
    Anybody knows how to do this?

  2. metalvalley
    Member
    Posted 6 years ago #

    Anybody?

  3. metalvalley
    Member
    Posted 6 years ago #

    This shouldn't be so hard to do??

  4. metalvalley
    Member
    Posted 6 years ago #

    p-p-p-p-pleaaaaaase help me with this!?!?

  5. metalvalley
    Member
    Posted 6 years ago #

    I guess there is no solution for this, although all other forums do have?

  6. metalvalley
    Member
    Posted 6 years ago #

    Stil not resolved!

  7. breger
    Member
    Posted 6 years ago #

    Try this:

    <?php global $user_identity;
    get_currentuserinfo();
    
    if ($user_identity == '') {
    echo('Welcome Guest');
    } else {
    echo('Welcome ' . $user_identity);
    }
    ?>

    This will show Welcome Guest. Or if the visitor is logged in it will show Welcome members name

  8. metalvalley
    Member
    Posted 6 years ago #

    That worked exactly as I wanted! Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic