You are here

function user_delete in Drupal 8

Same name and namespace in other branches
  1. 5 modules/user/user.module \user_delete()
  2. 6 modules/user/user.module \user_delete()
  3. 7 modules/user/user.module \user_delete()

Delete a user.


  Drupal::entityTypeManager->getStorage('user')->load($uid)->delete();

Parameters

int $uid: A user ID.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use the user entity's delete method to delete the user.

See also

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

1 call to user_delete()
UserLegacyTest::testUserDelete in core/modules/user/tests/src/Kernel/UserLegacyTest.php
Tests that user_delete throws a deprecation error.

File

core/modules/user/user.module, line 908
Enables the user registration and login system.

Code

function user_delete($uid) {
  @trigger_error("user_delete() is deprecated in drupal:8.8.0. Use the user entity's delete method to delete the user. See https://www.drupal.org/node/3051463", E_USER_DEPRECATED);
  user_delete_multiple([
    $uid,
  ]);
}