如何禁止非管理员收到wordpress更新通知

  • 时间:2020-05-20 15:19:20
  • 分类:网络文摘
  • 阅读:153 次

很多时候,我们不希望客户或会员更新自己的wordpress版本、主题或插件,以防止他们将wordpress核心设置搞乱。这里有一个wordpress技巧,可以设置wordpress的网站只有管理员才可以看到更新通知,而不是其他用户。你可以通过以下代码禁止非管理员收到wordpress的更新通知。

将如下代码复制到当前主题的functions.php模板文件中,并更新之:

  1. if ( !current_user_can( 'manage_options' ) ) {
  2.     //Disable Theme Updates
  3.     remove_action( 'load-update-core.php', 'wp_update_themes' );
  4.     add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );
  5.     wp_clear_scheduled_hook( 'wp_update_themes' );
  6.     //Disable Plugin Updates
  7.     remove_action( 'load-update-core.php', 'wp_update_plugins' );
  8.     add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
  9.     wp_clear_scheduled_hook( 'wp_update_plugins' );
  10.     //Diasable Core Updates
  11.     add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
  12.     wp_clear_scheduled_hook( 'wp_version_check' );
  13. }

这三段代码依次分别禁止非管理员收到wordpress主题、wordpress插件、wordpress版本的更新通知,你也可以根据自己的需要进行修改。

 

原文:http://www.trickspanda.com/2014/04/disable-update-notifications-non-administrators-wordpress/

推荐阅读:
Introducing the Pancake Sorting Algorithm  What Should You Blog About During the Pandemic and Beyond?  6 Tips For Starting a Business During a Pandemic  Will Your Blog be affected by the Current Facebook Ad Boycott?  Unobvious Life Hacks for Ads Optimization in Google  Essential Traits That Will Help Bloggers Work From Home Successf  Examining the Physical and Mental Health of Writers and Bloggers  How will Blogging Change after the Pandemic?  Digital Relationships: 5 Tips For Building A Better Veterinary B  The 2020 Pandemic Further Boosts Earnings and Influence of Blogg 
评论列表
添加评论