function user_load

user_load($uid, $reset = FALSE)

Loads a user object.

Parameters

int $uid: Integer specifying the user ID to load.

bool $reset: TRUE to reset the internal cache and load from the database; FALSE (default) to load from the internal cache, if set.

Return value

\Drupal\user\UserInterface A fully-loaded user object upon successful user load, or NULL if the user cannot be loaded.

Deprecated

in Drupal 8.x, will be removed before Drupal 9.0. Use \Drupal\user\Entity\User::load().

See also

\Drupal\user\Entity\User::loadMultiple()

File

core/modules/user/user.module, line 216
Enables the user registration and login system.

Code

function user_load($uid, $reset = FALSE) {
  if ($reset) {
    \Drupal::entityManager()->getStorage('user')->resetCache(array($uid));
  }
  return User::load($uid);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!user!user.module/function/user_load/8.1.x