简体   繁体   English

有什么办法可以在wordpress中为非管理员用户隐藏所有管理员通知?

[英]Is there any way to hide all admin notification for non admin users in wordpress?

Is there any way to all hide admin notification for non-admin users. 有没有办法为非管理员用户全部隐藏管理员通知。

I have used below code but it will hide only update notification but I need to hide all notification 我使用了下面的代码,但是它将仅隐藏更新通知,但我需要隐藏所有通知

 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 );

I'm also want to hide these type of notifications. 我也想隐藏这些类型的通知。

在此处输入图片说明

Try to insert the following code on your functions.php file of your active theme. 尝试在活动主题的functions.php文件中插入以下代码。 This code may disable all the updates notifications regarding plugins, themes & WordPress completely. 此代码可能会完全禁用有关插件,主题和WordPress的所有更新通知。

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');

I hope that this code works fine. 我希望这段代码能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM