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.

1 call to drush_user_cancel()
1 string reference to 'drush_user_cancel'
user_drush_command in commands/user/user.drush.inc
Implementation of hook_drush_command().

File

commands/user/user.drush.inc, line 303
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) {
    drush_print("Cancelling the user account with the following information:");
    _drush_user_print_info($uid);
    if (drush_get_option('delete-content') && drush_drupal_major_version() >= 7) {
      drush_print("All content created by this user will be deleted!");
    }
    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 {
    drush_set_error("Could not find a user account with the name " . $name . "!");
  }
}