function user_cancel_confirm_form_submit

Submit handler for the account cancellation confirm form.

See also

user_cancel_confirm_form()

user_multiple_cancel_confirm_submit()

1 call to user_cancel_confirm_form_submit()
user_multiple_cancel_confirm_submit in modules/user/user.module
Submit handler for mass-account cancellation form.

File

modules/user/user.pages.inc, line 575

Code

function user_cancel_confirm_form_submit($form, &$form_state) {
    global $user;
    $account = $form_state['values']['_account'];
    // Cancel account immediately, if the current user has administrative
    // privileges, no confirmation mail shall be sent, and the user does not
    // attempt to cancel the own account.
    if (user_access('administer users') && empty($form_state['values']['user_cancel_confirm']) && $account->uid != $user->uid) {
        user_cancel($form_state['values'], $account->uid, $form_state['values']['user_cancel_method']);
        $form_state['redirect'] = 'admin/people';
    }
    else {
        // Store cancelling method and whether to notify the user in $account for
        // user_cancel_confirm().
        $edit = array(
            'user_cancel_method' => $form_state['values']['user_cancel_method'],
            'user_cancel_notify' => $form_state['values']['user_cancel_notify'],
        );
        $account = user_save($account, $edit);
        _user_mail_notify('cancel_confirm', $account);
        drupal_set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.'));
        watchdog('user', 'Sent account cancellation request to %name %email.', array(
            '%name' => $account->name,
            '%email' => '<' . $account->mail . '>',
        ), WATCHDOG_NOTICE);
        $form_state['redirect'] = "user/{$account->uid}";
    }
}

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