Support » Plugins » Getting user id for user-edit.php

  • Resolved Daniel Bachhuber


    I’m adding an additional meta data field to user profiles. For the user that’s currently logged in, it’s a simple thing to use wp_get_current_user() to get their user id (for associating data within the database). If I’m logged in as an admin, however, and editing another user’s profile, I’m not quite sure how to get that user’s id (in order to pull and save the correct data).

    Thoughts? One idea is that I could strip it from the URL, but I feel as though it’s a hackish solution and there might be a better one. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Upon some serious internal reflection, I was able to deduce the answer (actually, it came from here):

    global $profileuser;
    $user_id = $profileuser->ID;

    $profileuser is apparently a global and rather accessible variable for user info.

    were you able to successfully add in user metadata through the user-edit page?

    i’m trying to do the same thing, and all the solutions i’ve found involve either kludgey plugins or things that add extra tables for their own data. meh.

    i’ve can set and get the data in my templates like so:

    $UserLevel = get_usermeta($userId,'level');

    but i’m stuck at being able to see/edit that field in the user edit page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting user id for user-edit.php’ is closed to new replies.