[wp-hackers] Hook being called twice on activate, once on deactivate

Austin Matzko if.website at gmail.com
Thu Oct 29 19:46:00 UTC 2009


On Thu, Oct 29, 2009 at 2:24 PM, mark waterous <mark at watero.us> wrote:
> register_activation_hook( __FILE__, call_user_func( 'wpdb_test_activate',
> $outside_data ) );

>
> This resulted in behavior I wasn't expecting - it would appear that the hook
> runs twice on activation. The first run strips $wpdb->prefix, the second
> time it doesn't. It also runs the activation hook again on deactivation.
> Should it be doing that? The actual plugin has a deactivation hook of
> course, but I wasn't expecting it to run the activation hook in absence of
> this.

That's not how to use register_activation_hook.  call_user_func()
there is calling the wpdb_test_activate function when it's defined,
which is when the file is read in, rather than when the activation
hook fires.

Should be something like register_activation_hook( __FILE__,
'wpdb_test_activate');

and then figure out another way to pass the $outside_data stuff.


More information about the wp-hackers mailing list