I couldn't find this in a search. I need to get the ID of the user who is accessing a module I am programming.

What is the PHP code I need to use to obtain this?
Is there a method that will return it or a global variable?
Or a session variable?

thanks for the help and advice.

Comments

behindthepage’s picture

The object $user contains lots of user info

global $user
$User_id = $user->uid;

put print_r($user) on a page and it will list at top of page all the info it contains

gpdinoz
"Everything should be made as simple as possible, but not simpler." - Albert Einstein

Regards
Geoff

jeditdog’s picture

Hey thanks, this worked. That makes sense.

Also I learned some new PHP. I didn't know print_r worked on Objects. I thought only arrays. Again thank you.