When managing a WordPress site, admin notifications can be helpful in keeping administrators updated about important information and system alerts. However, for non-admin users—such as editors, authors, or clients—these notifications may create unnecessary clutter and even reveal technical details that aren’t relevant to them. In this post, we’ll show you how to hide all WordPress admin notifications for non-admin users using PHP and CSS, and also explain how our Weblabs UI plugin can further optimize your admin dashboard for a streamlined experience.
One effective method to hide admin notifications for non-admins is to use PHP to conditionally remove these notifications. By checking a user’s capability (for example, using the manage_options
capability, which is typically reserved for administrators), you can remove all notifications from displaying for users without sufficient privileges.
<?php
// Hide all admin notifications for non-admin users
function hide_admin_notifications_for_non_admins() {
if ( ! current_user_can( 'manage_options' ) ) {
// Remove the admin_notices action to hide notifications for non-admins
remove_all_actions( 'admin_notices' );
}
}
add_action( 'admin_head', 'hide_admin_notifications_for_non_admins', 1 );
?>
This code snippet hooks into the admin header and checks whether the current user has the manage_options
capability. If they do not, it removes all actions hooked to admin_notices
, effectively preventing any admin notifications from being displayed on the dashboard. This ensures that non-admin users enjoy a cleaner and more focused admin experience.
In cases where you might not want to alter functionality via PHP or prefer a visual solution, you can hide admin notifications using custom CSS. This method doesn’t remove the notifications from the source code but simply prevents them from being visible in the dashboard.
/* Hide admin notifications for non-admin users */
.non-admin .notice,
.non-admin .update-nag,
.non-admin .error,
.non-admin .updated {
display: none !important;
}
You would need to add a custom body class (for instance, non-admin
) only for non-administrative users. You can do this with a small PHP snippet as well:
<?php
// Add a custom body class for non-admin users
function add_non_admin_body_class( $classes ) {
if ( ! current_user_can( 'manage_options' ) ) {
$classes .= ' non-admin';
}
return $classes;
}
add_filter( 'admin_body_class', 'add_non_admin_body_class' );
?>
By adding the above code to your theme’s functions.php
file or via a code snippet plugin, you ensure that non-admin users are assigned the non-admin
class. The attached CSS will then hide any elements styled as admin notifications.
While hiding admin notifications for non-admin users helps create a cleaner workspace, further enhancing your WordPress backend can offer even more benefits. This is where Weblabs UI comes into play.
Weblabs UI is a premium backend UI plugin for WooCommerce that transforms your admin dashboard into a sleek, modern interface. Beyond simple notification management, Weblabs UI provides:
By integrating Weblabs UI, you not only remove distractions for non-admin users but also provide an optimized, visually appealing interface for all users—ensuring that your WooCommerce store runs more efficiently.
Removing unnecessary admin notifications for non-admin users is a simple yet powerful way to simplify the WordPress dashboard and make it more user-friendly. Whether you choose a PHP-based solution that conditionally removes notifications or a CSS approach to hide them visually, both methods can significantly enhance the user experience by keeping technical clutter out of sight.
If you’re looking to take your back-end customization a step further, consider exploring Weblabs UI. Enhance your WooCommerce dashboard with advanced features, cleaner layouts, and an overall more efficient workflow. Secure a seamless, distraction-free admin experience today!