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

Fires immediately before a user is deleted from the database.

Parameters Parameters


(int) ID of the user to delete.


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

Top ↑

Source Source

File: wp-admin/includes/user.php

View on Trac

Top ↑

Changelog Changelog

Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by yongkiagustinus

    Example usage
    Send email notification when a user is deleted

    add_action( ‘delete_user’, ‘my_delete_user’ );
    function my_delete_user(){
    $user_data = get_userdata( $user_id );
    $headers = ‘From: ‘ . get_bloginfo( ‘name’ ) . ‘ ‘ . “\r\n”;
    wp_mail( $user_data->user_email, ‘We are deleting your account’, ‘Your account at ‘ . get_bloginfo( ‘name’ ) . ‘ will be deleted.’, $headers);

You must log in before being able to contribute a note or feedback.