WordPress.org

Ready to get started?Download WordPress

Forums

php command for currently logged in user (7 posts)

  1. jefpride
    Member
    Posted 8 years ago #

    I want to make a customized Dashboard for each user (i only have a few). Is there a way to query php for the name of the currently logged in user? Thanks!

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    From previous answers here about logged in users, you need to query the $User_ID ?

    (I know zero php, hence the vagueness)

  3. Anonymous
    Unregistered
    Posted 8 years ago #

    $user_identity is what you want for the name; of course you just need to echo it; <?php _e($user_identity); ?>

  4. jefpride
    Member
    Posted 8 years ago #

    That isnt quite doing it. here is some of the code i am trying to get working...:

    print ("Hi");
    echo $user_identity;
    print("<p style=\"font-weight:bold;color:gray;\">Hope you guys had a good week. Have a better weekend!");

    this, when executed, just leaves a blank where the user's id would be.

    Help! Thanks.

  5. jaseone
    Member
    Posted 8 years ago #

    Is that within a WordPress template or on it's own? If it is on its own you need to include some of the WordPress files first.

  6. jefpride
    Member
    Posted 8 years ago #

    the code above is entered into the custom message field of the dashboard options plugin and evaluated as php. so i suppose it is inserted in the wp-admin index. Is that what you were asking?

  7. Anonymous
    Unregistered
    Posted 8 years ago #

    It's quite possible $user_identity is not a local variable within the scope of the dashboard page; if that's the case, try making it global and seeing what happens (global $user_identity). I do know I used $user_identity just fine in a custom site template without declaring it global.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags