function hook_user_presave

Act on a user account being inserted or updated.

This hook is invoked before the user account is saved to the database.

Parameters

$account: The user account object.

See also

hook_user_insert()

hook_user_update()

Related topics

2 functions implement hook_user_presave()

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

entity_crud_hook_test_user_presave in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_user_presave().
system_user_presave in drupal/core/modules/system/system.module
Implements hook_user_presave().

File

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

Code

function hook_user_presave($account) {

  // Ensure that our value is an array.
  if (isset($account->mymodule_foo)) {
    $account->mymodule_foo = (array) $account->mymodule_foo;
  }
}