function user_user_presave in Drupal 7
Same name and namespace in other branches
- 8 core/modules/user/user.module \user_user_presave()
- 9 core/modules/user/user.module \user_user_presave()
- 10 core/modules/user/user.module \user_user_presave()
Implements hook_user_presave().
File
- modules/
user/ user.module, line 1303 - Enables the user registration and login system.
Code
function user_user_presave(&$edit, $account, $category) {
if ($category == 'account' || $category == 'register') {
if (!empty($edit['picture_upload'])) {
$edit['picture'] = $edit['picture_upload'];
}
elseif (!empty($edit['picture_delete'])) {
$edit['picture'] = NULL;
}
}
// Filter out roles with empty values to avoid granting extra roles when
// processing custom form submissions.
if (isset($edit['roles'])) {
$edit['roles'] = array_filter($edit['roles']);
}
// Move account cancellation information into $user->data.
foreach (array(
'user_cancel_method',
'user_cancel_notify',
) as $key) {
if (isset($edit[$key])) {
$edit['data'][$key] = $edit[$key];
}
}
}