function user_user_presave

Same name in other branches
  1. 9 core/modules/user/user.module \user_user_presave()
  2. 8.9.x core/modules/user/user.module \user_user_presave()
  3. 10 core/modules/user/user.module \user_user_presave()
  4. 11.x core/modules/user/user.module \user_user_presave()

Implements hook_user_presave().

File

modules/user/user.module, line 1317

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.