I have a plugin that currently doesn’t support network activation. The best fix for this of course is to fix it 🙂 which I plan to do. However I wonder if there is a temporary solution I can use to prevent network activation in the meantime, perhaps a workflow similar to:

  1. Detect if the activation is network-wide (how??)
  2. Display message that it’s currently not supported, and I stink, I’m sorry
  3. Interrupt the activation or deactivate

Or, other suggestions accepted. Thanks.

For clarification: Multisite activation is fine, just not network-wide activation.

4 s
4

The answers here are overthought and too complex. Why deactivating the plugin instead of preventing activation? Something as simple as calling die(‘your error message here) upon activation will do the job.

function activate($networkwide) {
    if (is_multisite() && $networkwide) 
       die('This plugin can\'t be activated networkwide');
}

register_activation_hook('your-plugin/index.php','activate');

Then when you try to activate in the panel, you will get a nice error on top of the page, with your error message.

Leave a Reply

Your email address will not be published. Required fields are marked *