W3cubDocs

/WordPress

do_action( ‘delete_user’, int $id, int|null $reassign, WP_User $user )

Fires immediately before a user is deleted from the site.

Description

Note that on a Multisite installation the user only gets removed from the site and does not get deleted from the database.

Parameters

$idint
ID of the user to delete.
$reassignint|null
ID of the user to reassign posts and links to.
Default null, for no reassignment.
$userWP_User
WP_User object of the user to delete.

More Information

The delete_user action/hook can be used to perform additional actions when a user is deleted. For example, you can delete rows from custom tables created by a plugin.

This hook runs before a user is deleted. The hook deleted_user (notice the “ed”) runs after a user is deleted. Choose the appropriate hook for your needs. If you need access to user meta or fields from the user table, use delete_user.

Users deleted from Network Site installs may not trigger this hook. Be sure to use the wpmu_delete_user hook for those cases. The deleted_user hook is called in either case.

Source

do_action( 'delete_user', $id, $reassign, $user );

Changelog

Version Description
5.5.0 Added the $user parameter.
2.0.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/delete_user