How to use is_multisite() in a must-use-plugin?

MU-Plugins load very early– earlier that your theme or your normal plugins. Because of that, you sometimes need to hook functions that you would otherwise not have to hook.

add_action(
  'plugins_loaded',
  function () {
    if (( is_multisite() && !current_user_can('manage_network') ) || ( !is_multisite() && !current_user_can('create_users')))  {
      add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
      add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
      add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
    }
  }
);

The plugins_loaded hook basically means the function will execute just after the normal plugins load, and that seems to be late enough and reasonable to boot.

Leave a Comment