User Delete Remove Custom Table Information

Wordpress Is providing the solution to how to delete the all information of users when user is deleted by admin. Go to the theme folder and open functions.php and insert the below code.


Define this on functions.php

/*
* Delete User data Code Start 20131024 Alok Tiwari
*/
function user_data_delete($user_id)
{
global $wpdb;

//$wpdb->query("DELETE FROM wp_membership WHERE user_id=$user_id");
}

add_action('delete_user', 'user_data_delete' );
/*
* Delete User Data Code End
*/

Call the action hook “delete_user” and also define the function under the function write query for deleting the information of user.

Leave a Comment

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