In a recent project, we needed to delete some data from a custom table when a user was deleted. After about 10 minutes of searching on Google, we found the solution below.
Note: When a user is deleted, the “delete_user” action is called, as shown below.
add_action( ‘delete_user’, ‘function_name’ );
Let me explain, step by step, how to delete data from a custom table.
In our case, we had to delete data from six tables, as shown in the screenshot.

The PHP code is below.
Check it out and let me know if you have any questions. Let me know if you have any questions via the contact page. Happy to help.

