nutsmuggler
Member
Posted 7 years ago #
Hi. I am buidling a plugin that creates a new table and some options to the wp data base. ThusI need to eliminate the table and aoptions when the plugin is uninstalled.
Where do I hook in?
I tried
if (isset($_GET['deactivate']) && $_GET['deactivate'] == 'true') {
add_action('init', 'dbes_uninstall');
}
to call the dbes_uninstall function.
Yet this doesn't seem to work...
Any suggestion?
Thanks in advance,
Davide
Hey. That's because WordPress doesn't get to your code when WP deactivates your plugin. It takes it out of the include cycle as soon as the button is pressed.
Also, I recommend not having your plugin completely uninstall itself when it is deactivated. There isn't a ton of harm in having idle tables, and users might squawk when their data disappears. I have two plugins that install their own tables, and I never run any uninstall code.
Cheers
nutsmuggler
Member
Posted 7 years ago #
Ok, i see.
It was obvious ...
Anyway, leaving the table would do no harm, but I must get rid of the options somehow, and of a specific page built by the plugin...
Is there any strategy to perform a php script when uninstalling a plugin?
Cheers,
Davide