简体   繁体   中英

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. This code may disable all the updates notifications regarding plugins, themes & WordPress completely.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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