Title: error when deactivating custom plugin
Last modified: August 19, 2016

---

# error when deactivating custom plugin

 *  Resolved [philbert_mcpleb](https://wordpress.org/support/users/philbert_mcpleb/)
 * (@philbert_mcpleb)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/)
 * I am writing a small plugin to manage some downloads, currently i am still setting
   up the basics but have run into a problem.
 * When i try to deactivate the plugin i get the error below
 * Warning: call_user_func_array() [function.call-user-func-array]: First argument
   is expected to be a valid callback, ‘WP_download_manager::deactivate’ was given
   in /home/philbert/web-published/devbert/test1/wp-includes/plugin.php on line 
   339
 * the same deactivation function and hook is used in another or my plugins and 
   works without issue. does anyone have any ideas?
 * thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Mike Challis](https://wordpress.org/support/users/mikechallis/)
 * (@mikechallis)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/#post-1270530)
 * It would be hard to comment on unseen code. Do you have a code sample?
 *  Thread Starter [philbert_mcpleb](https://wordpress.org/support/users/philbert_mcpleb/)
 * (@philbert_mcpleb)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/#post-1270577)
 * 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');
       		}
       ```
   
 *  [Mike Challis](https://wordpress.org/support/users/mikechallis/)
 * (@mikechallis)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/#post-1270886)
 * 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/](http://wordpress.org/extend/plugins/si-contact-form/)
 *  Thread Starter [philbert_mcpleb](https://wordpress.org/support/users/philbert_mcpleb/)
 * (@philbert_mcpleb)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/#post-1270928)
 * 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.
 *  Thread Starter [philbert_mcpleb](https://wordpress.org/support/users/philbert_mcpleb/)
 * (@philbert_mcpleb)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/#post-1270957)
 * Just been able to try the changes you suggested. they seem to be working well.
   Many thanks

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘error when deactivating custom plugin’ is closed to new replies.

 * 5 replies
 * 2 participants
 * Last reply from: [philbert_mcpleb](https://wordpress.org/support/users/philbert_mcpleb/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/error-when-deactivating-custom-plugin/#post-1270957)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
