Title: Need help with Deactivation script
Last modified: August 19, 2016

---

# Need help with Deactivation script

 *  [ninjakreborn](https://wordpress.org/support/users/ninjakreborn/)
 * (@ninjakreborn)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/need-help-with-deactivation-script/)
 * Hello. I have been doing programming and stuff like that for 7 years. I am VERY
   good with PHP and other stuff. This is one of my first times doing any real word
   press development. I already have a good installation function/hook. I am trying
   to now write a De-activation function/hook. I have the hook working (I think)
   but it’s not removing the tables on uninstall. If possible, can someone review
   the code and give me feedback.
    Thank you again for your support.
 *     ```
       function basketball_team_analyzer_uninstall() {
       	global $wpdb;
   
       	$table_name1 = $wpdb->prefix . "wpbta_basketball_players";
       	$table_name2 = $wpdb->prefix . "wpbta_basketball_teams";
       	$table_name3 = $wpdb->prefix . "wpbta_basketball_teammapping";
       	$table_name4 = $wpdb->prefix . "wpbta_basketball_projectedstats";
       	$table_name5 = $wpdb->prefix . "wpbta_basketball_actualstats";
   
       	$sql =  "DROP table " . $table_name1 . ";";
       	$sql .= "DROP table " . $table_name2 . ";";
       	$sql .= "DROP table " . $table_name3 . ";";
       	$sql .= "DROP table " . $table_name4 . ";";
       	$sql .= "DROP table " . $table_name5 . ";";      
   
             require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
       	  $wpdb->query($sql);
       }
   
       // Call to create DB upon activation
       register_deactivation_hook(__FILE__, 'basketball_team_analyzer_uninstall');
       ?>
       ```
   
 * This is not removing the database tables on uninstall.
    Any help is greatly appreciated.

Viewing 1 replies (of 1 total)

 *  Thread Starter [ninjakreborn](https://wordpress.org/support/users/ninjakreborn/)
 * (@ninjakreborn)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/need-help-with-deactivation-script/#post-1774828)
 * Sorry to re-bump, but I am still having an issue with this. Basically when I 
   activate the script it works fine. All the files are installed. But when I Deactivate,
   it does not remove all of the tables.
 * Any help with this would be greatly appreciated.

Viewing 1 replies (of 1 total)

The topic ‘Need help with Deactivation script’ is closed to new replies.

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [ninjakreborn](https://wordpress.org/support/users/ninjakreborn/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/need-help-with-deactivation-script/#post-1774828)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
