2016-06-15 46 views
0

有什么办法可以隐藏非管理员用户的管理员通知。有没有什么办法可以隐藏WordPress管理员的所有管理员通知?

我用下面的代码,但它会隐藏仅更新通知,但我需要隐藏所有通知

function hide_update_notice_to_all_but_admin_users() 
    { 
     if (!current_user_can('update_core')) { 
      remove_action('admin_notices', 'update_nag', 3); 
     } 
    } 
    add_action('admin_head', 'hide_update_notice_to_all_but_admin_users', 1); 

我也想隐藏这些类型的通知。

enter image description here

回答

0

尝试插入您的当前主题的functions.php文件下面的代码。此代码可能会完全禁用所有关于插件的更新通知,主题&。

function remove_core_updates(){ 
    global $wp_version; 
    return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,); 
} 
add_filter('pre_site_transient_update_core','remove_core_updates'); 
add_filter('pre_site_transient_update_plugins','remove_core_updates'); 
add_filter('pre_site_transient_update_themes','remove_core_updates'); 

我希望这段代码能正常工作。

相关问题