Forums

register_activation_hook / register_deactivation_hook (4 posts)

  1. dvg
    Member
    Posted 9 months ago #

    So ... I just don't understand what's happening here.

    I'm written a class for my plugin, and register_deactivation_hook works, but register_activation_hook doesn't.

    class Foo{
       function Foo(){
          register_activation_hook( __FILE__, array( &this, "initializeFoo" );
          register_deactivation_hook( __FILE__, array( &this, "killFoo" );
       }
    
       function initializeFoo(){
          add_option( "foo_start", 1 );
       }
    
       function killFoo(){
          add_option( "foo_die", 1 );
       }
    }
    
    add_action( 'plugins_loaded', 'loadThePlugin' );
    
    function loadThePlugin(){
    	global $Foo;
    	$Foo = new Foo();
    }

    When I activate the plugin, register_activation_hook appears not to fire, but when I deactivate it, register_deactivation_hook does. (The option appears in the database for foo_die, but not foo_start.)

    Help?

  2. dvg
    Member
    Posted 9 months ago #

    Typo: I correctly have a $ in front of the this object.

    &$this is how I have it in the plugin; still doesn't work

  3. Gale Andrews
    Member
    Posted 6 months ago #

    Mine either. I wish someone could answer these questions about register_activation_hook so this wont be such a big issue.

    [you have made your point - now stop spamming numerous threads with it - samboll]

  4. nkuttler
    Member
    Posted 2 months ago #

    activation hook is fired before plugins_loaded... code is poetry...

Reply

You must log in to post.

About this Topic