I'm making a module for Drupal, and in many of my functions I use the global $user object, which contains information about the currently logged in user. However, in one of my functions the $user object always seems to display information for the admin user (user ID 1). It never contains information about the user that's currently viewing the page, like it should. What are some things that would cause a global variable to misbehave like this? I can't for the life of me figure out why this is happening.
What happens if you specifically pass the value of $user to the function? Like: function user_info($user) { } user_info($user); Does it still do the same thing?
yes, you can send variables using properties to functions. But by declaring $GLOBALS['user'] you can use it everywhere without adding it to function properties.