delete_user WordPress Action Hook

The delete_user hook is called when a user is deleted from the WordPress site. This hook can be used to perform custom actions when a user is deleted, such as deleting their data from a custom database table.

do_action( 'delete_user', int $id, int|null $reassign, WP_User $user ) #

Fires immediately before a user is deleted from the database.


Parameters

$id

(int)ID of the user to delete.

$reassign

(int|null)ID of the user to reassign posts and links to. Default null, for no reassignment.

$user

(WP_User)WP_User object of the user to delete.


Top ↑

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.


Top ↑

Source

File: wp-admin/includes/user.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.5.0Added the $user parameter.
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.