Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function user_load
Same name and namespace in other branches
- 8.9.x core/modules/user/user.module \user_load()
Loads a user object.
Drupal has a global $user object, which represents the currently-logged-in user. So to avoid confusion and to avoid clobbering the global $user object, it is a good idea to assign the result of this function to a different local variable, generally $account. If you actually do want to act as the user you are loading, it is essential to call drupal_save_session(FALSE); first. See Safely impersonating another user for more information.
Parameters
$uid: Integer specifying the user ID to load.
$reset: TRUE to reset the internal cache and load from the database; FALSE (default) to load from the internal cache, if set.
Return value
A fully-loaded user object upon successful user load, or FALSE if the user cannot be loaded.
See also
48 calls to user_load()
- comment_tokens in modules/
comment/ comment.tokens.inc - Implements hook_tokens().
- EntityCrudHookTestCase::testUserHooks in modules/
simpletest/ tests/ entity_crud_hook_test.test - Tests hook invocations for CRUD operations on users.
- hook_file_copy in modules/
system/ system.api.php - Respond to a file that has been copied.
- hook_file_move in modules/
system/ system.api.php - Respond to a file that has been moved.
- hook_file_update in modules/
system/ system.api.php - Respond to a file being updated.
File
-
modules/
user/ user.module, line 365
Code
function user_load ($uid, $reset = FALSE) {
$users = user_load_multiple (array(
$uid,
), array(), $reset);
return reset ($users);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.