hook_user_presave

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 hook_user_presave(&$edit, $account, $category)

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.

$account The user object on which the operation is performed.

$category The active category of user information being edited.

See also

hook_user_insert()

hook_user_update()

Related topics

Code

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

<?php
function hook_user_presave(&$edit, $account, $category) {
  // Make sure that our form value 'mymodule_foo' is stored as 'mymodule_bar'.
  if (isset($edit['mymodule_foo'])) {
    $edit['data']['my_module_foo'] = $edit['my_module_foo'];
  }
}
?>