You are here

function user_load in Drupal 8

Same name and namespace in other branches
  1. 4 modules/user.module \user_load()
  2. 5 modules/user/user.module \user_load()
  3. 6 modules/user/user.module \user_load()
  4. 7 modules/user/user.module \user_load()

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.0.0 and is removed from drupal:9.0.0. Use Drupal\user\Entity\User::load().

See also

https://www.drupal.org/node/2266845

1 call to user_load()
UserLegacyTest::testEntityLegacyCode in core/modules/user/tests/src/Kernel/UserLegacyTest.php
@expectedDeprecation user_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\user\Entity\User::loadMultiple(). See https://www.drupal.org/node/2266845 @expectedDeprecation user_load() is deprecated in…

File

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

Code

function user_load($uid, $reset = FALSE) {
  @trigger_error('user_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\user\\Entity\\User::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED);
  if ($reset) {
    \Drupal::entityTypeManager()
      ->getStorage('user')
      ->resetCache([
      $uid,
    ]);
  }
  return User::load($uid);
}