0

I've been working on migrating one of my plugins to support multisite installs and am attempting to figure out the cleanest way to handle the following series of events:

  1. Plugin is Network Activated
  2. New site is added

I'm currently listening to the activation hook which works for every other case, both individual activations and site-wide ones, but I'm not getting an activation hit when the new site is added. Incidentally, this strikes me as a bug in WP core... In any event, I need to catch this series of events and run activation things.

I was looking at combining the wpmu_create_blog hook and is_plugin_active_for_network, but I'm not sure if there might fingers crossed be a better way to do this.

1 Answer 1

1

After looking through Make WordPress, it looks like this is a known issue that won't be fixed due to scalability concerns with large networks.

That same issue linked above recommends doing exactly the solution discussed above. Specifically, that would look something like this:

public static function 145561_activate_new_blog($blog_id) {
   if (is_plugin_active_for_network(plugin_basename(__FILE__))) {
      // do activation for $blog_id
   }
}
add_action('wpmu_new_blog', '145561_activate_new_blog');

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.