function drush_user_cancel

8.0.x user.drush.inc drush_user_cancel($inputs)
6.x user.drush.inc drush_user_cancel($name)
7.x user.drush.inc drush_user_cancel($inputs)
4.x user.drush.inc drush_user_cancel($name)
5.x user.drush.inc drush_user_cancel($name)
master user.drush.inc drush_user_cancel($inputs)

Cancels a user account.

File

commands/user/user.drush.inc, line 356
Drush User Management commands

Code

function drush_user_cancel($name) {
  if (drush_drupal_major_version() >= 7) {
    $result = db_query("SELECT uid FROM {users} WHERE name = :name", array(':name' => $name));
  }
  else {
    $result = db_query("SELECT uid FROM {users} WHERE name = '%s'", $name);
  }
  $uid = drush_db_result($result);
  if ($uid !== FALSE) {
    if (drush_get_option('delete-content') && drush_drupal_major_version() >= 7) {
      drush_log("All content created by this user will be deleted.", 'ok');
    }
    if (drush_confirm('Cancel user account?: ')) {
      if (drush_drupal_major_version() >= 7) {
        if (drush_get_option('delete-content')) {
          user_cancel(array(), $uid, 'user_cancel_delete');
        }
        else {
          user_cancel(array(), $uid, 'user_cancel_reassign');
        }
        // I got the following technique here: http://drupal.org/node/638712
        $batch = &batch_get();
        $batch['progressive'] = FALSE;
        batch_process();
      }
      else {
        user_delete(array(), $uid);
      }
    }
  }
  else {
    return drush_set_error("Could not find a user account with the name " . $name . ".");
  }
}