Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function user_delete_multiple

Same name and namespace in other branches
  1. 8.9.x core/modules/user/user.module \user_delete_multiple()

Delete multiple user accounts.

Parameters

$uids: An array of user IDs.

1 call to user_delete_multiple()
user_delete in modules/user/user.module
Delete a user.

File

modules/user/user.module, line 2623

Code

function user_delete_multiple (array $uids) {
 if (!empty($uids)) {
 $accounts = user_load_multiple ($uids, array());
 $transaction = db_transaction ();
 try {
 foreach ($accounts as $uid => $account) {
 module_invoke_all ('user_delete', $account);
 module_invoke_all ('entity_delete', $account, 'user');
 field_attach_delete ('user', $account);
 drupal_session_destroy_uid ($account->uid);
 }
 db_delete ('users')->condition ('uid', $uids, 'IN')
 ->execute ();
 db_delete ('users_roles')->condition ('uid', $uids, 'IN')
 ->execute ();
 db_delete ('authmap')->condition ('uid', $uids, 'IN')
 ->execute ();
 } catch (Exception $e) {
 $transaction->rollback ();
 watchdog_exception ('user', $e);
 throw $e;
 }
 entity_get_controller ('user')->resetCache ();
 }
}

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