function user_cancel

Same name and namespace in other branches
  1. 11.x core/modules/user/user.module \user_cancel()
  2. 10 core/modules/user/user.module \user_cancel()
  3. 9 core/modules/user/user.module \user_cancel()
  4. 8.9.x core/modules/user/user.module \user_cancel()
  5. 7.x modules/user/user.module \user_cancel()

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.

Parameters

array $edit: An array of submitted form values.

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

string $method: The account cancellation method to use.

Deprecated

in drupal:11.5.0 and is removed from drupal:13.0.0. Use \Drupal::service(AccountCancellation::class)->cancel() instead.

See also

https://www.drupal.org/node/3620934

AccountCancellation::cancelAccount()

File

core/modules/user/user.module, line 204

Code

function user_cancel($edit, $uid, $method) : void {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Use \\Drupal::service(AccountCancellation::class)->cancel() instead. See https://www.drupal.org/node/3620934', E_USER_DEPRECATED);
  \Drupal::service(AccountCancellation::class)->cancel($edit, $uid, $method);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.