Title: Uninstall.php for my plugin
Last modified: August 21, 2016

---

# Uninstall.php for my plugin

 *  [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * (@eherman24)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/uninstallphp-for-my-plugin/)
 * I keep finding conflicting ways to write an uninstall.php file for your plugin.
   I know how to delete_options, I’m just not sure If the beginning of my uninstall.
   php is correct. I’ve found two articles that say to do it differently:
 * Codex:
 *     ```
       //if uninstall not called from WordPress exit
       if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
       	exit ();
   
       delete_option('example');
       ```
   
 * and alternate source (wptuts):
 *     ```
       if(defined('WP_UNINSTALL_PLUGIN') ){  
   
         //delete options, tables or anything else  
   
       }
       ```
   
 * So which is the correct way? I’m leaning towards the wptuts way, but only because
   it seems to make a bit more sense to me.
    Thanks guys

Viewing 1 replies (of 1 total)

 *  [Rod Whiteley](https://wordpress.org/support/users/rod-whiteley/)
 * (@rod-whiteley)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/uninstallphp-for-my-plugin/#post-4082583)
 * I prefer the second way if there is not much code. But I prefer the first way
   if there is a lot of code, because I do not like `{` and `}` to be far apart.

Viewing 1 replies (of 1 total)

The topic ‘Uninstall.php for my plugin’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Rod Whiteley](https://wordpress.org/support/users/rod-whiteley/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/uninstallphp-for-my-plugin/#post-4082583)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
