You could check if the constant SITE_ID_CURRENT_SITE
matches get_current_site()->id
. The following does this for the activation. During runtime you have to check it again.
register_activation_hook( __FILE__, 'force_main_site_installation' );
function force_main_site_installation()
{
if ( defined( 'SITE_ID_CURRENT_SITE' )
and SITE_ID_CURRENT_SITE !== get_current_site()->id
)
{
if ( function_exists('deactivate_plugins') )
{
deactivate_plugins( __FILE__ );
}
die( 'Install this plugin on the main site only.' );
}
}
Related Posts:
- Prevent network activation of plugin
- 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
- Change the_title() of a page dynamically
- Adding more options to the instance of an image. (Attachment Display Settings)
- Trouble with Transient API when W3TC is activated [closed]
- Rewrite Point Doesn’t Work on Custom Taxonomy
- Should shorcodes in i18n plugins be translated and if so, how?
- Show User’s Current Time
- Where did the ability to edit a plugin go?
- Adding custom end points, No error line
- automatic change post date when post is 30 days old
- wp_editor add media button not working
- Plugin Development – Class Constructor Not Firing wp_enqueue_style action hook
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Add quick edit functionnality to plugin table
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- add pagination to wp_remote_get
- How to get option values without requiring wp-load?
- Call API on post save/update and show the result in admin area
- Is there any other ways to replicating changes on live from staging without pushing from git