It would be hard to comment on unseen code. Do you have a code sample?
here are the functions that activate and deactivate the plugin.
register_activation_hook(__File__, array('WP_download_manager', 'activate'));
register_deactivation_hook(__File__, array('WP_download_manager', 'deactivate'));
//add actions for the types of pages to display
add_action('admin_menu', 'WP_download_manager_admin');
function activate()
{
//stuff plugin should do on activation goes here
$data = array('title' => "WPDM_option");
if ( ! get_option('WPDM_option'))
{ add_option('WPDM_option' , $data); }
else
{ update_option('WPDM_option' , $data); }
}
function deactivate()
{
//deactivation commands go here
delete_option('WPDM_option');
}
In my plugins, I only delete options with the register_uninstall_hook. Because if you use the register_deactivation_hook options will be deleted with automatic plugin upgrades, or if an admin deactivates plugins for troubleshooting reasons.
The code you posted will not work.
This is what I would do:
register_activation_hook(__File__,'wp_download_manager_activate');
// options deleted when this plugin is deleted in WP 2.7+
if ( function_exists('register_uninstall_hook') ) {
register_uninstall_hook(__FILE__,'wp_download_manager_delete');
}
function wp_download_manager_activate()
{
//stuff plugin should do on activation goes here
$data = array('title' => "WPDM_option");
if ( ! get_option('WPDM_option'))
{ add_option('WPDM_option' , $data); }
else
{ update_option('WPDM_option' , $data); }
}
function wp_download_manager_delete()
{
//delete commands go here
delete_option('WPDM_option');
}
If you are using a class, your function wp_download_manager_deactivate must not be in the class or it will not work.
Also you should not use too generic function names or they will clash with other plugins or WP itself (notice I changed them)
You can look at one of my plugins if you want to see how I do it.
http://wordpress.org/extend/plugins/si-contact-form/
thanks for that, i can’t test it for a few days as i have no home internet until my ISP fixes it. i will let you know how i get on.
Just been able to try the changes you suggested. they seem to be working well. Many thanks