Title: Plugin: deactivating functions
Last modified: August 18, 2016

---

# Plugin: deactivating functions

 *  [nutsmuggler](https://wordpress.org/support/users/nutsmuggler/)
 * (@nutsmuggler)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/plugin-deactivating-functions/)
 * 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

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [jalenack](https://wordpress.org/support/users/jalenack/)
 * (@jalenack)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/plugin-deactivating-functions/#post-291528)
 * 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
 *  Thread Starter [nutsmuggler](https://wordpress.org/support/users/nutsmuggler/)
 * (@nutsmuggler)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/plugin-deactivating-functions/#post-291544)
 * 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

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Plugin: deactivating functions’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [nutsmuggler](https://wordpress.org/support/users/nutsmuggler/)
 * Last activity: [20 years, 6 months ago](https://wordpress.org/support/topic/plugin-deactivating-functions/#post-291544)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
