I’m totally new to WordPress and php. I have a custom table in my WordPress plugin and I want to delete the custom table when deactivating the plugin (NO when uninstalling it).
This is easy to accomplish but before deleting the table I want to ask for confirmation.
function va_deactivation() {
.... //unregisters settings
//Asks for confirmation - Code here
//If answer is yes proceed to delete. If no, doesn't execute the following code
global $wpdb;
$pa_table = $wpdb->prefix."tableName";
$sql = 'DROP TABLE IF EXISTS '.$pa_table;
$wpdb->query( $sql );
}
Any help? Thanks
I used this in my case
but its better to use register_uninstall_hook