Opened 8 years ago
Closed 5 months ago
#128 closed enhancement (fixed)
Add unistall option for wp-contactform
| Reported by: | soteke | Owned by: | ryanduff |
|---|---|---|---|
| Priority: | normal | Component: | wp-contact-form |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Perhaps it would be a goog thing if people could uninstall the plugin by deleting the options inserted into the database. If you think this is a goof idea, hope the following code will help:
<div class="wrap" id="uninstall">
<h2>Uninstall Plugin</h2>
<p> To uninstall this plugin (erase the options this plugin ads to your database) please write 'Uninstall' in the following form and press the 'Go' button.<p>
<form name="uninstall_wpcf" method="POST">
<INPUT TYPE="text" NAME="confirmation" size="40" value="">
<input type="submit" name="erase" value="Go">
</div>
<?
global $wpdb, $table_prefix;
if(isset($_REQUESTerase?) && $_POSTconfirmation?=='Uninstall'){
$wpdb->query("DELETE FROM {$table_prefix}options WHERE option_name = 'wpcf_email'");
$wpdb->query("DELETE FROM {$table_prefix}options WHERE option_name = 'wpcf_show_quicktag'");
$wpdb->query("DELETE FROM {$table_prefix}options WHERE option_name = 'wpcf_error_msg'");
$wpdb->query("DELETE FROM {$table_prefix}options WHERE option_name = 'wpcf_success_msg'");
$wpdb->query("DELETE FROM {$table_prefix}options WHERE option_name = 'wpcf_subject'");
echo "<div class='wrap'>Options were deleted successfully please deactivate the plugin to complete uninstall.</div>";
die();
}
?>
Change History (2)
comment:1 Changed 8 years ago by ryanduff
comment:2 Changed 5 months ago by qurl
- Resolution set to fixed
- Status changed from new to closed
In 639724:

Wordpress 1.6 has just added plugin hooks for things to run on the loading/unloading of plugins. WPCF 2.0 is possibly being targeted at the Wordpress 1.6 release and will include a removal function.
Besides, there's no need for a complex SQL query, its built into wordpress already...
add_option(), update_option(), and delete_option()