In some cases we may want to delete data related to certain post stored in some custom table (i.e. data which is currently not in wordpress).

If the data related to a post is not in wordpress then it won’t get cleaned once the post is deleted from the wordpress and you may end up garbage and unmanageable data in your custom table.

e.g. we have a custom post to register attendees to our events. There is also a need to log if the user had attended previous events too and to maintain their preferences for each year/event. Since it is not possible to store such yearwise/eventwise data in wordpress through custom fields, we may end up creating our own custom table.

The requirement is when the user gets deleted from the system, the data stored about the user in the custom table should also get deleted

WordPress provides a hook to clean such data stored in your custom table.

 

 

One Comment

Leave a Reply

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