WordPress version 3.4.2
Here is the simplest form of plugin with only two hooks:
register_activation_hook(__FILE__, sbv_activate());
register_deactivation_hook(__FILE__, sbv_deactivate());
function sbv_activate() {
add_option('sbv_opt1', 'test');
}
function sbv_deactivate() {
delete_option('sbv_opt1');
}
I went to check the option table after I activate this plugin, seems like the option is not there, if I remove the delete_option() line from the deactivation function, it will work. Correct me if I am wrong, seems like wordpress is calling sbv_activate() then sbv_deactivate(), thus undoing what I have done in activation, I don’t think it should behave like this. I am going crazy with this.
You should be using only the name of the function not the function itself:
WP Codex reference: http://codex.wordpress.org/Function_Reference/register_activation_hook