Get uid of logged user
marcuscavalcanti - January 31, 2007 - 19:02
I created a personal profile page called 'user_profile_tpl.php'.
In this page I need to recover the uid of the user is logged, but when i print the $user->uid, the id that it is returned me is of the user who is being edited and not of what he is logged.
How to i get the uid of the user is logged?

Not clear...
I use $user->uid in my custom profile page to create the custom profile page for each user.
when I want to get the uid of person who has written a node I use
$ka->uid = $node->uid;profile_load_profile($ka);
When I want to get he person who is logged in I use:
global $user; and $user->uid ;I suppose you after the last one.
Harjoituspäiväkirja - www.lenkkivihko.fi
The answer probably lies in your override
Most people override theme_user_profile something like this
<?php/**
* Catch the theme_profile_profile function, and redirect through the template api
*/
function phptemplate_user_profile($user, $fields = array()) {
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
// will be assigned within your template.
/* potential need for other code to extract field info */
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
}
?>
and the part that reads
'user' => $usermakes the variable $user available as $user in user_profile_tpl.php which means the global $user is hidden. If you need both change'user' => $userto'account' => $user, then in user_profile.tpl.php change all uses of $user to $account. Then you can declare $user as global and reference data about the person logged in (using $user).Maybe a little to late for
Maybe a little to late for the party...
but simply use $_GLOBALS['user'] when your "global $user" is hidden!
is it possible to use this
is it possible to use this way in snippet?