You are here

function user_multiple_cancel_confirm_submit in Drupal 7

Submit handler for mass-account cancellation form.

See also

user_multiple_cancel_confirm()

user_cancel_confirm_form_submit()

File

modules/user/user.module, line 3434
Enables the user registration and login system.

Code

function user_multiple_cancel_confirm_submit($form, &$form_state) {
  global $user;
  if ($form_state['values']['confirm']) {
    foreach ($form_state['values']['accounts'] as $uid => $value) {

      // Prevent programmatic form submissions from cancelling user 1.
      if ($uid <= 1) {
        continue;
      }

      // Prevent user administrators from deleting themselves without confirmation.
      if ($uid == $user->uid) {
        $admin_form_state = $form_state;
        unset($admin_form_state['values']['user_cancel_confirm']);
        $admin_form_state['values']['_account'] = $user;
        user_cancel_confirm_form_submit(array(), $admin_form_state);
      }
      else {
        user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']);
      }
    }
  }
  $form_state['redirect'] = 'admin/people';
}