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.
Related Posts:
- Only allow plugin to be activated on root site of multisite
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Custom Plugin activation error in Multisite
- How do I create a custom role capability?
- How to redirect to settings page once the plugin is activated?
- How to output message during plugin activation
- Inserting Taxonomy Terms During a Plugin Activation?
- Uninstall script for a plugin in Multisite
- Changing Plugin Load Order
- What is wrong with using add_option with Multisite instead of add_blog_option in a plugin
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Cron firing my function everytime wp-admin is visited
- Using wp_cron with custom time interval and the register activation hook
- Error getting correct blog_id on MU from functions.php
- How do I make specific plugin functionality apply to different sites in a network?
- WordPress multisite apply different options over each site from same plugin
- Call activation hook multiple times
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- Multisite, sharing content by URL
- How to use wp_set_password in a plugin?
- WordPress Media mime type filter problem 4.0
- why creating tables using $wpdb is not being executed while installing plugins?
- Override pluggable functions in a plugin?
- Plugin activation error due to unexpected output
- What is the best way to overwrite /wp-admin/ms-delete-site.php
- Where should I store global data for my multi-site WordPress plugin?
- unable to stop loop when using wp_insert_post with publish_post hook
- Customize multisite site creation with user data
- Multisite plugin development and wp_enqueue_script
- Plugin Uninstall and Deactivate via Options Menu
- how to activate plugin network-wide, and save setting across sites
- Sharing a common set of image files for media library, across all sites within multisite
- What is difference between blog id and site id?
- Settings not set after calling register_setting()
- How to create a Tools menu on the Network Admin dashboard from a plugin
- Override the default Add/Edit site forms of the Network Panel in custom plugin
- How to set “Site Address (URL)” programmatically on WP multisite?
- How to associate an existing user to a site in a multisite setup programmatically
- WordPress Multisite with Azure B2C redirect_urls after Login
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- How To Change Post Author Default?
- Adding (blog-specific) links to “My Sites” admin page
- Plugin menu addition in multisite
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Multiple Plugin best practice in Multisite
- Selectively update themes in WordPress multisite
- Problem with context in multisite – getting main site data in every blog (get_pages())
- how to invoke wordpress API from other existing PHP system
- WP Multisite login not working on one subsite. Possibly cookies/ history issue?
- register_activation_hook on multisite
- Add Link Category on Activation?
- WordPress Plugin Activate / Deactive Failing
- WordPress multisite,use same cookies across all website?
- WP: Search and replace in DB programmatically
- Multiple array for post_content on plugin activation
- Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘Blocks\Base\Activation’ not found
- How to get current logged-in user details in multisite?
- add_action wp_ajax_ not loading in plugin file WP Network
- Plugin can’t be activated [closed]
- Activate / Deactivate plugin
- How to share user data across multiple WordPress websites?
- Is there anything special required to make a plugin work in a multisite environment?
- How to edit wp-signup.php content using plugin
- Activation flow of a plugin in a multisite environment
- How do I ensure I can loop through every enqueued script and CSS?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Replace “content-area” of themes 404 page with plugin?
- Multisite and the JSON REST API: How to?
- How to store in the database directly the translation?
- Testing Plugins for Multisite
- Unable to show a message after plugin activation
- Same header/footer in Admin, across all network sites in multisite
- Refresh or redirect page after activate my plugin
- I can install my plugin in localhost but not in my server
- WordPress plugin tables become corrupt
- Change Admin menu placement using hooks
- Deactivate plugin on registration
- Force remove parent theme CSS/JS and call them from Child theme
- how can a plugin return an error message on activation?
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- My activator class isn’t running the code inside
- ajaxurl not defined on front end
- Create a Page via plugin
- Build a translation correcter plugin
- How do I debug an error that a plugin is causing?
- Need edit profile link in the menu for logged in users
- How to create a database table in WordPress using PHP
- Render raw html in Gutenberg block
- How can I create a custom plugin to call webapi after user registration?
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Rest Api WordPress
- How to create A – Z List with pictures?
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- A better way of getting draft posts that has a particular post meta using get_posts function
- Save translation file of third party plugin in a custom plugin?
- Custom rewrite, url path with parameters to a page
- Developing an IP lookup function using an API
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- how to add contact form 7 shortcode in javascript variable
- select rows based on exact time (hours, minutes and seconds)