0

I am in need to do some operation if user clicks on Network Activate button on my WP Plugin (in WP Multisite).

But I noticed that Wordpress's is_plugin_active_for_network function not working for multisites when I press the Network Activate button from the Main Administrator Panel.

It returns nothing, and hence the

if(is_plugin_active_for_network('abc/abc.php'))

is not fulfilled.

However when the Network is already Network Activated then the function - is_plugin_active_for_network is working fine (It returns 1 - i.e. true).

Can anyone please tell me how can I check whether the Network Activate button is clicked by the main administrator?

1 Answer 1

1

You need to check that when you are activating the plugin. WordPress will send a Boolean flag to let your function know that this is a network wide activation.

register_activation_hook( __FILE__, 'activate' );

function activate( $network_wide ) {

    // $network_wide will be TRUE if activation is network wide
    if ( $network_wide  ) {

        ... Do Stuff ...

    }

    ...

}
1
  • It doesn't work. I am using OOP approach in activating the plugin. $network_wide does not have any value all the times.
    – Thompson
    Commented Aug 23, 2014 at 18:59

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.