function hook_user_presave
A user account is about to be created or updated.
This hook is primarily intended for modules that want to store properties in the serialized {users}.data column, which is automatically loaded whenever a user account object is loaded, modules may add to $edit['data'] in order to have their data serialized on save.
Parameters
$edit: The array of form values submitted by the user. Assign values to this array to save changes in the database.
$account: The user object on which the operation is performed. Values assigned in this object will not be saved in the database.
$category: The active category of user information being edited.
See also
Related topics
7 functions implement hook_user_presave()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- block_user_presave in modules/
block/ block.module  - Implements hook_user_presave().
 - contact_user_presave in modules/
contact/ contact.module  - Implements hook_user_presave().
 - EntityCrudHookTestHooks::userPresave in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ src/ Hook/ EntityCrudHookTestHooks.php  - Implements hook_ENTITY_TYPE_presave() for user entities.
 - entity_crud_hook_test_user_presave in modules/
simpletest/ tests/ entity_crud_hook_test.module  - Implements hook_user_presave().
 - overlay_user_presave in modules/
overlay/ overlay.module  - Implements hook_user_presave().
 
1 invocation of hook_user_presave()
- user_save in modules/
user/ user.module  - Save changes to a user account or add a new user.
 
File
- 
              modules/
user/ user.api.php, line 244  
Code
function hook_user_presave(&$edit, $account, $category) {
  // Make sure that our form value 'mymodule_foo' is stored as
  // 'mymodule_bar' in the 'data' (serialized) column.
  if (isset($edit['mymodule_foo'])) {
    $edit['data']['mymodule_bar'] = $edit['mymodule_foo'];
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.