function user_delete_multiple in Drupal 7
Same name and namespace in other branches
- 8 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 2603 - Enables the user registration and login system.
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();
}
}