WordPress.org

Ready to get started?Download WordPress

Forums

How do you get logged-in username? (6 posts)

  1. carbontwelve
    Member
    Posted 6 years ago #

    I'm currently writing a plugin and need to know how to get the current username & id ive searched for about an hour but found nothing.

  2. MichaelH
    Member
    Posted 6 years ago #

    Check out the setup_userdata function in wp-includes/user.php.

    setup_userdata($current_user->ID);
  3. Mindshare Studios, Inc.
    Member
    Posted 6 years ago #

    I'm trying to figure this out also...this code isn't working to get the logged in username (or email in this case):

    $current_user = setup_userdata($current_user->ID);
    echo $current_user->$user_email;

    This is being executed by a plugin -not sure if that effects it.

  4. MichaelH
    Member
    Posted 6 years ago #

    Found this in Function_Reference/get_currentuserinfo

    <?php global $user_ID;
          get_currentuserinfo();
    
          if ('' == $user_ID) {
             //no user logged in
          }
    ?>
  5. MichaelH
    Member
    Posted 6 years ago #

  6. JAB Creations
    Member
    Posted 6 years ago #

    <?php echo $user_identity; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic