Title: Self-deactivate plugin ?
Last modified: August 19, 2016

---

# Self-deactivate plugin ?

 *  [primo411](https://wordpress.org/support/users/primo411/)
 * (@primo411)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/self-deactivate-plugin/)
 * Hi, i’m writing a plugin that uses his own table in the database. I want that,
   when the plugin is deactivated from the plugins list, the database is kept. Besides,
   i have add a button to the plugin options page to uninstall it properley, droping
   all tables. But I cannot find how to make my plugin deactivate himslef after 
   that. I thought that would work, but it doesn’t:
 *     ```
       $this->aixorder_deactivate(); //droping my tables (works, tested)
       $plugin = plugin_basename(__FILE__);
        do_action('deactivate_'.$plugin); //plugin is not deactivated, and i land on my plugins options page full of errors because my database table was dropped...
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [primo411](https://wordpress.org/support/users/primo411/)
 * (@primo411)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/self-deactivate-plugin/#post-767039)
 * Well, I have a beginning answer… I misunderstood the do_action function: it justs
   creates a new hook. What i search is how to force the deactivation of the plugin
   and land on the plugin list.

Viewing 1 replies (of 1 total)

The topic ‘Self-deactivate plugin ?’ is closed to new replies.

## Tags

 * [deactivate](https://wordpress.org/support/topic-tag/deactivate/)

 * 1 reply
 * 1 participant
 * Last reply from: [primo411](https://wordpress.org/support/users/primo411/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/self-deactivate-plugin/#post-767039)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
