Prevent network activation of plugin

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 Comment