I have created a plugin where I want to call two different functions on activation.

Is there a best way to do this?

Should I use register_activation_hook twice? As in:

register_activation_hook( __FILE__, 'function_1' );
register_activation_hook( __FILE__, 'function_1' );

Or call the two functions from within an activation function, as in:

register_activation_hook( __FILE__, 'my_activation_function' );
function my_activation_function () {



Any ideas? Thanks.

  • Just a note: adding multiple instances of register_activation_hook does work - though it may not be the right way to do it. Jun 21, 2014 at 2:56

1 Answer 1


My approach to this would be to have a start_activation() method that calls the other methods.

register_activation_hook( __FILE__, array( 'my_plugin_loader', 'start_activation' ) );

class my_plugin_loader {
    function start_activation() {
        $this->func1(); // or self::func1();
        $this->func2(); //    self::func2(); for static methods
     function func1() {
         // do stuff
     function func2() {
         // do other stuff

I'm not saying it is the "right" way, just how I would approach it.

  • This is what I've gone for, though using the procedural way in my original post. It works fine. Thanks for the method/OOP variant! Jun 21, 2014 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.