Forums

[resolved] How to get all of the activate_plugin action parameters? (2 posts)

  1. AmberKayle
    Member
    Posted 1 year ago #

    I am trying to hook into activate_plugin.

    I know that activate_plugin has 1 required param and 2 optional ones. I am trying to acquire all 3.

    Here's my setup:

    // create plugin settings menu
    add_action('admin_menu', 'pe_create_menu');
    
    function pe_create_menu() {
    
      //create new sub-level menu
      add_submenu_page( 'plugins.php', 'Plugin Settings', 'Plugin Enabler', 'administrator', __FILE__, 'pe_settings_page' );
    
      // Add my hook
      add_action( 'activate_plugin', 'pe_network_activate', 10, 3 );
    }

    And my function:

    function pe_network_activate( $plugin, $redirect = '', $network_wide = false ) {
      $args = var_export( func_get_args(), true);
      _log("Args: " . $args); // write to the WP error_log
    }

    $args returns only the first parameter. How do I get all 3?

    My goal is to be able to tell when a plugin is being network activated, or just normally activated - hence the need for $network_wide.

  2. AmberKayle
    Member
    Posted 1 year ago #

    Found out that activate_plugin accepts 3 args, but the action only emits 1.

    Going to monitor update_site_option.

Topic Closed

This topic has been closed to new replies.

About this Topic