hook_user_presave
- Versions
- 7
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, and the module needs to prepare the stored data in some way. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
See also
@see hook_user_update()
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.
Related topics
Code
modules/user/user.api.php, line 217
<?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['mymodule_bar'] = $edit['mymodule_foo'];
// Inform user_save() to ignore the value of our property.
$edit['mymodule_foo'] = NULL;
}
}
?>Login or register to post comments 