How do I run my custom function in my plugin when a wordpress user is deleted?

I have a custom function in my plugin, I want to run it when any of the wordpress user is deleted so i can know that a user and which user was deleted.
I implemented this but it is’nt working.

function my_delete_user( $user_id ) {
global $wpdb;
require_once(ABSPATH.’wp-admin/includes/user.php’ );
$user_obj = get_userdata( $user_id );
$email = $user_obj->user_email;

$headers = ‘From: ‘ . get_bloginfo( “name” ) . ‘ <‘ . get_bloginfo( “admin_email” ) . ‘>’ . “rn”;
wp_mail( $email, ‘You are being deleted, brah’, ‘Your account at ‘ . get_bloginfo(“name”) . ‘ is being deleted right now.’, $headers );
}
add_action( ‘delete_user’, ‘my_delete_user’ );

but this is not working, as it should send a mail. I want to know which user was deleted from their email.

Read more here:: How do I run my custom function in my plugin when a wordpress user is deleted?

Leave a Reply

Your email address will not be published. Required fields are marked *