function hook_user_update

Respond to updates to a user account.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the update operation is entirely completed and \Drupal\user\DataStorageController::save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check \Drupal\user\DataStorageController::save() and db_transaction() for more info.

Parameters

$account: The user account object.

See also

hook_user_presave()

hook_user_insert()

Related topics

4 functions implement hook_user_update()

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

block_user_update in drupal/core/modules/block/block.module
Implements hook_user_update().
contact_user_update in drupal/core/modules/contact/contact.module
Implements hook_user_update().
entity_crud_hook_test_user_update in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_user_update().
overlay_user_update in drupal/core/modules/overlay/overlay.module
Implements hook_user_update().

File

drupal/core/modules/user/user.api.php, line 290
Hooks provided by the User module.

Code

function hook_user_update($account) {
  db_insert('user_changes')
    ->fields(array(
    'uid' => $account->uid,
    'changed' => time(),
  ))
    ->execute();
}