Skip navigation


7 user.module user_cancel($edit, $uid, $method)

Cancel a user account.

Since the user cancellation process needs to be run in a batch, either Form API will invoke it, or batch_process() needs to be invoked after calling this function and should define the path to redirect to.


$edit: An array of submitted form values.

$uid: The user ID of the user account to cancel.

$method: The account cancellation method to use.

See also


3 calls to user_cancel()


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


function user_cancel($edit, $uid, $method) {
  global $user;

  $account = user_load($uid);

  if (!$account) {
    drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error');
    watchdog('user', 'Attempted to cancel non-existing user account: %id.', array('%id' => $uid), WATCHDOG_ERROR);

  // Initialize batch (to set title).
  $batch = array(
    'title' => t('Cancelling account'), 
    'operations' => array(),

  // Modules use hook_user_delete() to respond to deletion.
  if ($method != 'user_cancel_delete') {
    // Allow modules to add further sets to this batch.
    module_invoke_all('user_cancel', $edit, $account, $method);

  // Finish the batch and actually cancel the account.
  $batch = array(
    'title' => t('Cancelling user account'), 
    'operations' => array(
      array('_user_cancel', array($edit, $account, $method)),

  // Batch processing is either handled via Form API or has to be invoked
  // manually.