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
2010-10-25 22:44:12
+1 That's some good points, though you should be careful with devel on a production site.
googletorp
2010-10-26 02:15:14
I was talking about the template, sorry not to clarify, and thanks for the answer!
Andrew
2010-10-26 06:38:44
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
2010-10-26 00:56:38
A:
Use the Devel module and you will get every kind of information you wanted.
Vivek Saurabh
2010-10-26 12:38:14
A:
do a print_r($node) in the correct file or use devel like Vivek suggested
Thor
2010-10-26 13:24:07