Forums

[resolved] Display visitor user name in widgets (2 posts)

  1. Alyson
    Member
    Posted 3 years ago #

    What i need is to display the visitors user name.
    so if Tom logs in, at the top of the page it needs to say "Hey Tom,"

    I try this:

    <?php
    global $current_user;
    if ( isset($current_user) ) {
    echo $current_user->user_login;
    }
    ?>

    What i need to do before?
    this?

    <?php $current_user; ?>

    I have no sucess.

    And i try this function:

    function get_username() {
    global $current_user;
    if ( isset($current_user) )
    echo $current_user->user_login;
    }

    with:

    <?php $current_user; ?>

    And not happen :(

    Thanks for all suport.

  2. Alyson
    Member
    Posted 3 years ago #

    I resolved this problem using:

    in: user.php
    insert this:

    function get_username() {
    global $current_user;
    if ( isset($current_user) )
    echo $current_user->user_login;
    }

    in widgets.php
    insert this:

    Welcome <?php get_username() ?>

    this is all :D
    cya

Topic Closed

This topic has been closed to new replies.

About this Topic