When I look at $user like this
global $user dpm($user);
I do not see the user account fields I added. How can I access them?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
The global variable
$user doesn't contain all the properties you would find in a user object; in particular, it doesn't contain the fields associated with the user entity. If you need the complete user object, you need to use the following code.
$account = user_uid_optional_load();
Without any argument, user_uid_optional_load() returns the user object loaded from the database for the currently logged in user. If you have a user ID (e.g. you don't need the user object for the currently logged in user, but the user ID is passed to your function as parameter), then it is better to use the following code.
$account = user_load($uid);