function hook_user_delete
Respond to user deletion.
This hook is invoked from user_delete_multiple() before field_attach_delete() is called and before users are actually removed from the database.
Modules should additionally implement hook_user_cancel() to process stored user data for other account cancellation methods.
Parameters
$account: The account that is being deleted.
See also
Related topics
11 functions implement hook_user_delete()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- comment_user_delete in modules/
comment/ comment.module  - Implements hook_user_delete().
 - EntityCrudHookTest::userDelete in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php  - Implements hook_ENTITY_TYPE_delete() for user entities.
 - EntityCrudHookTestHooks::userDelete in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ src/ Hook/ EntityCrudHookTestHooks.php  - Implements hook_ENTITY_TYPE_delete() for user entities.
 - entity_crud_hook_test_user_delete in modules/
simpletest/ tests/ entity_crud_hook_test.module  - Implements hook_user_delete().
 - HistoryHooks::userDelete in core/
modules/ history/ src/ Hook/ HistoryHooks.php  - Implements hook_ENTITY_TYPE_delete() for user entities.
 
1 invocation of hook_user_delete()
- user_delete_multiple in modules/
user/ user.module  - Delete multiple user accounts.
 
File
- 
              modules/
user/ user.api.php, line 47  
Code
function hook_user_delete($account) {
  db_delete('mytable')->condition('uid', $account->uid)
    ->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.