Trigger event/external request when woocommerce plugin is installed/uninstalled?

How do I detect a new install or uninstall of a woocommerce plugin?
I haven’t find any reference in their documentation.

Related posts

1 comment

  1. Yes there are two actions triggered upon plugins activation and deactivation. These are two the actions activated_plugin and deactivated_plugin

    You may use them like this

    function detect_plugin_activation(  $plugin, $network_activation ) {
        if( $plugin == "woocommerce/woocommerce.php" ) {
            // Woocommerce activated
            // Do your stuff here
        }   
    }
    add_action( 'activated_plugin', 'detect_plugin_activation', 10, 2 );
    
    function detect_plugin_deactivation(  $plugin, $network_activation ) {
        if( $plugin == "woocommerce/woocommerce.php" ) {
            // Woocommerce deactivated
            // Do your stuff here
        }   
    }
    add_action( 'deactivated_plugin', 'detect_plugin_deactivation', 10, 2 );
    

    There is one more action triggered by woocommerce itself at the time activation

    function on_woocommerce_installed() {
        // This action triggered exclusivly by woocommerce at the time of activation
    }
    add_action( 'woocommerce_installed', 'on_woocommerce_installed' );
    

Comments are closed.