function user_load_multiple

Same name in other branches
  1. 7.x modules/user/user.module \user_load_multiple()

Loads multiple users based on certain conditions.

This function should be used whenever you need to load more than one user from the database. Users are loaded into memory and will not require database access if loaded again during the same page request.

Parameters

array $uids: (optional) An array of entity IDs. If omitted, all entities are loaded.

bool $reset: A boolean indicating that the internal cache should be reset. Use this if loading a user object which has been altered during the page request.

Return value

array An array of user objects, indexed by uid.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\user\Entity\User::loadMultiple().

See also

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

1 call to user_load_multiple()
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 223

Code

function user_load_multiple(array $uids = NULL, $reset = FALSE) {
    @trigger_error('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', E_USER_DEPRECATED);
    if ($reset) {
        \Drupal::entityTypeManager()->getStorage('user')
            ->resetCache($uids);
    }
    return User::loadMultiple($uids);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.