function hook_user_load

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

3 functions implement hook_user_load()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

anonymous_user_unblock_test_user_load in modules/user/tests/anonymous_user_unblock_test.module
Implements hook_user_load().
entity_crud_hook_test_user_load in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_user_load().
profile_user_load in modules/profile/profile.module
Implements hook_user_load().

File

modules/user/user.api.php, line 26

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;
    }
}

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