I have a custom plugin I created that adds some custom meta input fields to every post

I want to remove all this plugin generated rows of postmeta for each post when I uninstall/delete the plugin

what code should I add to the plugin php file to do this?

Take a look at the documentation for register_uninstall_hook. There is as well a register_deactivation_hook function which can be usefull as well.

You could use them for calling a function which will remove the data from DB. But you should be careful and maybe let user check a checkbox to do so.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.