If I deactivate the plugin, the database table does not get removed. It is removed only when i delete the plugin. Here's my code:

register_deactivation_hook( __FILE__, 'my_plugin_remove_database' );
function my_plugin_remove_database() {
     global $wpdb;
     $table_name = $wpdb->prefix . 'sandbox';
     $sql = "DROP TABLE IF EXISTS $table_name";
}   ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.