views:

63

answers:

4

I'm logged in as admin, and go to view a user's account page. How can I get the id of the user I'm viewing, rather than the $user->uid (which would be the admin user id)?

+3  A: 

The user's ID is in the URL of the user edit form.

http://example.com/user/1/edit

If you have the devel module installed (and you should), there'll also be a devel tab on the user's profile page that'll let you see other information about the user.

If you're talking about the user's profile template (i.e. you're overriding user-profile.tpl.php), the user you're viewing is in the $account variable.

ceejayoz
+1 That's some good points, though you should be careful with devel on a production site.
googletorp
I was talking about the template, sorry not to clarify, and thanks for the answer!
Andrew
A: 

If you are using hook_form_FORMID_alter for the user_profile_form page/form, you can access it in the first variable that way:

function MODULENAME_form_user_profile_form_alter(&$form, &$form_state){

    // $form['#uid'] contains the uid of the user whose profile you're editing

}
wildpeaks
A: 

Use the Devel module and you will get every kind of information you wanted.

Vivek Saurabh
A: 

do a print_r($node) in the correct file or use devel like Vivek suggested

Thor