WordPress 2.7 Plugin Uninstall Methods
If you like this post, please subscribe to our RSS feed to read our new posts every day.
WordPress 2.7 Plugin Uninstall Methods: A tutorial from Jacob Santos on the WordPress 2.7 Plugin Uninstall functionality and how to use it to make the uninstall process easy and seamless. Jacob adds a note to all plugin authors that I believe is worth mentioning: Special care then should be taken when using this method to ensure that your plugin isn’t doing anything it shouldn’t when uninstalling. In other words, please be careful and do not break other plugins and/or the core.
Visitors who read this post, also read:
Related posts from the past
- WordPress Plugin Uninstall Tool
- Uninstall - Is There Such A Thing?
- Uninstalling Conundrum Part 2
- APAD: Simple Forum
- APAD: Genki Announcement
- How to get featured in our Daily Releases
- WordPress comment spam stoppage techniques
- APAD: Search and Replace
- APAD: Simple Spam Filter
- Plugin Deactivation Issues Solved With Actions and Filters

(4 votes, average: 4 out of 5)











Comments RSS
To put the quote in context, if you use the uninstall.php method, then you don’t have to worry about plugins which use their main plugin file to “bootstrap” other parts of code. The plugin is running code outside of functions, which WordPress has no control over. The plugin is deactivated, and in order to run the uninstall hook, the plugin has to be included for a short time in order to run that code.
Some plugins might assume that since they are being included that they should check whether their option exists or do other strange tasks that belong in functions or the activation hook. In other words, they think they are being activated, when they are actually bein uninstalled.
Special care also has to be made with the uninstall.php file to make sure that some interested party doesn’t stumble upon the uninstall.php file and then have it launch into the uninstall process. There are two constants that can be checked to ensure that event doesn’t happen.
Hey, thanks for the link by the way. It should make its way into the codex once 2.7 is released and the feature is still in there.
[Reply]
Jacob Santos — 08/8/2008 @ 7:18 pmI think the uninstall API can be improved before I switch from my own plugin uninstaller to the WP plugin uninstaller as I think my own uninstaller has more user forgiveness and tells the user what options or tables are going to be deleted.
[Reply]
GaMerZ (29 comments.) — 08/8/2008 @ 11:55 pmI haven’t looked at the 2.7 uninstall api yet, but I’d like to say that the uninstall function that Lester includes in his plugins is top notch. I’ve been meaning to add something like that to my plugins. I guess I’ll try out the API method, but if Lester thinks it can be improved, he should be listened to!
[Reply]
Stephen Cronin (20 comments.) — 08/9/2008 @ 8:02 am@Stephen Thanks so much for the kind compliments =)
[Reply]
GaMerZ (29 comments.) — 08/9/2008 @ 12:25 pmThe uninstaller only runs during the delete process, therefore it should be assumed that the user doesn’t want to use your plugin any more. From that, you can assume that everything should go, including all tables, options, and files that were created by the plugin.
[Reply]
Jacob Santos — 08/9/2008 @ 4:02 pm