WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

The activate_plugin() function accepts three parameters, but it emits the activate_plugin action with only one parameter. This can be confusing, but hooks sometimes use the same name as the function they come from, without passing the same parameters.

One way to get the difference between a network activation and a regular activation is to monitor the update_site_option and update_option hooks. Only one of them will fire, depending on the $network_wide parameter of activate_plugin().

share|improve this answer
Aaah didn't know that. Thanks! – AmberKayle Feb 2 '11 at 15:43

What do you need var_export() for? func_get_args() should give you array of arguments on its own.

share|improve this answer
I was following example 2 from the manual (php.net/manual/en/function.func-get-args.php) of how to use it. I wanted to see what I was getting. Editted my post to make that a bit more clear. – AmberKayle Feb 1 '11 at 21:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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