• I’m using an HTML form for my Users. Then I’m sending that form to a PHP file to a query to insert rows into a database.

    I’ve been trying use get_userdata() to pass information into the PHP file, but I’m having trouble figuring out what I need to do.

    What’s the syntax or tag I use to get that information?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jwrbloom

    (@jwrbloom)

    I figured it out.

    
    global $current_user;
    
    $user = $current_user->user_login;
    $userID = $current_user->ID;
    
    Thread Starter jwrbloom

    (@jwrbloom)

    And for those super newbies, the $user and $userID can be any variable you want it to be.

    Moderator bcworkz

    (@bcworkz)

    Thanks for coming back and posting the solution you figured out.

    FWIW, you could instead use wp_get_current_user(). It essentially does the same as you did in getting a global value. It does so in a more robust manner though, so it is more reliable in certain contexts where the global value may not yet be stable.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing User information to forms…’ is closed to new replies.