You are here

function delete_all_users_submit in Delete all 5

Same name and namespace in other branches
  1. 6 delete_all.module \delete_all_users_submit()
  2. 7 delete_all.module \delete_all_users_submit()

File

./delete_all.module, line 432

Code

function delete_all_users_submit($form_id, &$form) {
  $result = db_query('SELECT uid FROM {users} WHERE uid > 1');
  $count = 0;
  while ($data = db_fetch_object($result)) {
    user_delete(array(), $data->uid);
    $count++;
  }

  // Delete the URL aliases
  db_query("DELETE FROM {url_alias} WHERE src LIKE 'user/%%'");
  db_query("UPDATE {sequences} SET id = 1 WHERE name = 'users_uid'");
  drupal_set_message(t('All users have been deleted. Number of users deleted: !count.', array(
    '!count' => $count,
  )));
  drupal_goto('admin');
}