Is it actually a necessity to auto delete all the corresponding table rows when users are attempting to delete my plugin?

From my experience, I've encountered a few plugins where the db tables would still be existent within my database even after deletion.

I know it might appear as a sloppy job to keep the tables after deletion; but in some cases I could imagine that if an user would accidentally delete my plugin then he/she could end up losing a lot of data because of it.

2 Answers 2


In my opinion, a best practice would be to clean everything on uninstallation. It's also mentioned as a best practice in the docs:

When your plugin is uninstalled, you’ll want to clear out any plugin options and/or settings specific to to the plugin, and/or other database entities such as tables.

However, if you're struggling to decide what's best for your plugin, why not let the user decide? You could always ask them whether they want to keep their data just after they have clicked the uninstall button. Take a look at this similar question for details.


It's not the right way to delete tables from the database when you deactivate the plugin because there are many reasons that users can deactivate the plugin, but you can use an alternate way register_uninstall_hook for more information you may check the documentation for removing tables from database.

Hope this may help to you!

  • Thanks for letting me know! Only just realized this as well, Going to look into it right now :)
    – Gianni
    Commented Nov 6, 2019 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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