1

I want this code to be executed in a plugin in the mu-plugins folder. When executing in functions.php everything works fine, but when I try it as a plugin in mu-plugins this creates a blank page.

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;" ) );
}
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.