By marcuscavalcanti on
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?
Comments
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
When I want to get he person who is logged in I use:
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
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?
Actually, $GLOBALS['user']
Actually, $GLOBALS['user']
In profile page, you can use
In profile page, you can use $user->uid directly. And in other pages, $user is defined as a global variable. This post explains how to get user id in drupal: drupal get user id