You are here

function administerusersbyrole_form_user_multiple_delete_confirm_alter in Administer Users by Role 6

Implements hook_form_FORM_ID_alter().

File

./administerusersbyrole.module, line 128
Non-displayable characters.

Code

function administerusersbyrole_form_user_multiple_delete_confirm_alter(&$form, &$form_state) {
  $anyallowed = FALSE;
  foreach (array_filter($form_state['post']['accounts']) as $uid => $value) {
    $account = user_load($uid);
    if (_administerusersbyrole_can_delete_user($account)) {
      $anyallowed = TRUE;
    }
    else {
      drupal_set_message(t('You do not have permission to delete %user.', array(
        '%user' => $account->name,
      )), 'error');
      unset($form_state['post']['accounts'][$uid]);
      unset($form['accounts'][$uid]);
    }
  }
  if (!$anyallowed) {
    drupal_goto(drupal_substr($form['#action'], 1));
  }
}