[wp-hackers] do_action() inside the callback for the register_activation_hook()... doesn't work?

Austin Matzko austin at ilfilosofo.com
Tue Sep 7 17:59:26 UTC 2010


On Tue, Sep 7, 2010 at 12:38 PM, Davit Barbakadze <jayarjo at gmail.com> wrote:
> Basically I've got plugin class extending framework class which does
> some dirty staff for it, like creating/updating tables and options
> upon activation, etc. What I wanted was to trigger an action at the
> end of  register_activation_hook callback, after all the dirty work
> has been done, leaving a space for plugin specific extension. But a
> callback hooked onto the corresponding action, never gets called.
> Hence the assumption that it isn't possible to trigger an action from
> within the register_activation_hook() callback. Is it so? Why?

Probably what's happening is that you haven't attached the callbacks
to that action hook you're trying call, at least within the same page
load as when your activation hook gets called.

When you activate a plugin, function activate_plugin() includes the
plugin file as part of a test to make sure that the plugin doesn't
throw any fatal errors.  However, it does so after many common action
events have already occurred: "plugins_loaded," "init," etc.  That
means that any callbacks attached to those action hook events won't
happen when activate_plugin() does its next step--triggering the
activation hook.

Instead of attaching a callback to an action hook and then triggering
the action hook, why don't you just call the callback function
directly?


More information about the wp-hackers mailing list