function hook_user_load

hook_user_load($users)

Act on user objects when loaded from the database.

Due to the static cache in user_load_multiple() you should not use this hook to modify the user properties returned by the {users} table itself since this may result in unreliable results when loading from cache.

Parameters

$users: An array of user objects, indexed by uid.

See also

user_load_multiple()

profile_user_load()

Related topics

File

modules/user/user.api.php, line 26
Hooks provided by the User module.

Code

function hook_user_load($users) {
  $result = db_query('SELECT uid, foo FROM {my_table} WHERE uid IN (:uids)', array(':uids' => array_keys($users)));
  foreach ($result as $record) {
    $users[$record->uid]->foo = $record->foo;
  }
}

© 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/modules!user!user.api.php/function/hook_user_load/7.x