function hook_user_presave

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. 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

hook_user_insert()

hook_user_update()

Related topics

File

modules/user/user.api.php, line 244
Hooks provided by the User module.

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_presave/7.x