WordPress admin notices, how to hide them and create them

Every time you access the WordPress desktop it is common that you find some messages at the top of your screen, they are the WordPress administration notices.

Why WordPress administration notices are important

They are typically used to alert the user of important information, such as updates, warnings or errors.

Although you may think they are annoying, these admin notices can actually be quite useful in the right circumstances.

Admin prompts can guide you on tasks you need to perform, such as updating plugins or WordPress itself, how to fix bugs, and even how to fix technical issues.

However, it is also true that there are developers who abuse this tool, and sometimes WordPress admin notices are overused, turning them into something annoying and useless, because when there are too many notices the user tends not to read any of them.

In this article I want to show you the different types of administration notices there are, what each one is for, and how to manage them correctly, even hiding those that are not important.

Types of WordPress administration prompts

There are 4 types of situations that WordPress, plugins and themes can inform you about via admin notices.

Each of these types of notices are displayed in a block with a white, blue or yellow background, with different colored borders, which can help you quickly identify what type of notice it is.

Achievement notice (green border)

When you manage to make a change in WordPress, either in some settings or in the publication of content, activate a plugin, etc., this type of administration notice is displayed, which you will identify by the green border.

Warning notice (yellow border)

This notice can already be considered as an alert, and it appears when the user is warned about some issue.

It is the type of admin warning you will see when a plugin is not working properly, updates are available, and other situations where WordPress, plugins and themes feel they should warn you of a pending action.

These warning notices are distinguished by the yellow border.

Information notice (blue border)

This type of notice is purely informational and you can ignore them most of the time. They are distinguished by the blue border.

Error notice (red border)

Error messages appear when something goes wrong with your website. They are shown with a red border.

WooCommerce notices (purple border)

In addition to the standard WordPress ads we’ve seen before, recently other plugins have started using this feature to launch warning messages to their users.

One of them is WooCommerce, which usually displays its ads with the border in purple, lilac, or whatever you call it.

What are management notices useful for?

Apart from WordPress’ own admin notices, you can also use them as a way to contact your users for important issues if you are a plugin or theme developer, or even create custom admin notices on your own website to inform users of any important site issues or warnings. We’ll look at how to make them later.

The problem of too many WordPress administration warnings

Despite the obvious benefits of alerting users to important information about WordPress via admin alerts, every now and then the debate arises about the actual usefulness of these alerts for users. Especially when it comes to theme and plugin alerts.

In particular, there are several types of notices that can be particularly annoying…

Sales and marketing notices

Some developers use the notices to promote and sell other products from the WordPress desktop, which is often really annoying.

This is always the case to cross-sell pro versions of plugins and themes, and especially terrible on dates like Christmas or Black Friday, when they come to practically hijack WordPress admin screens.

Notices of minor issues

One of the main reasons why management warnings become annoying to users is when developers add warnings that are not really necessary.

For example, warnings about background processes that can be dismissed are usually irrelevant – and annoying – to most users.

Recurrent notices

Then there is the excess of repetitive warnings from some plugins, reminding you of this or that setting, especially when you can’t dismiss those warnings.

Any admin prompt without an icon or button to close it is an intrusion into the users’ workspace.

And the worst ones are those that, even if you close them, keep popping up again and again.

Data tracking notices

Also, more and more developers are adding notices to users offering to track and process their plugin usage data, statistics, etc.

This can be suspicious for anonymous users accessing the WordPress administration for minor issues.

How to control and hide WordPress administration notices

At this point you’re probably already thinking about whether there will be a way to control, even remove WordPress admin notices, leaving the useful ones and hiding the unnecessary ones.

And yes, we have several ways to achieve this, with and without plugins.

How to completely hide WordPress administration notices

If you are sure about everything that needs to be done on your website, one option – which I do not recommend – could be to completely hide all WordPress administration notices, no matter what color they are.

We have 2 ways to achieve this:

With a code

If you are already decided, add this code to the end of the functions.php file of the active child theme or to your customizations plugin:

/* Hide all notices WP */ add_action('admin_head', 'wphelp_hide_notices_wp'); function wphelp_hide_notices_wp() { ?> <style> .notice { display: none;} </style> <?php }
Code language: JavaScript (javascript)

With a plugin

Nothing could be easier!

Install and activate the Hide Admin Notices plugin and that’s it, you won’t even see the notice that you have activated the plugin, all admin notices disappear.

There are no settings, just activate and that’s it.

If, for some reason, you want to see the admin notices after activating the plugin, it gives you a new tab in the WordPress administration, next to the display options, from which you can show the hidden notices at any time.

I think this is a very smart solution for responsible administrators who, while safeguarding the workspace by hiding the alerts, still want to provide a way to view the various alerts, in case there are any important ones to review.

How to selectively hide WordPress administration notices

Another possibility is that you prefer to hide WordPress administration notices selectively, rather than completely.

Let’s take a look at several possibilities.

Hide warnings only to non-administrator users

This option is almost always chosen by webmasters or WordPress site maintainers.

It is a good solution for the administrator to see the notices that can be useful for their work, while avoiding those annoying messages to users who simply create content or manage orders.

As always in WordPress, there are 2 ways to achieve this:

With a code

To make the warnings visible only to administrators, and not to users with lower profiles and capabilities, add this code to the functions.php file of the active theme or to the customizations plugin you have created, as before:

/* Hide admin WP notices to users */ add_action('admin_enqueue_scripts', 'wphelp_hide_notice_wp_users'); add_action('login_enqueue_scripts', 'wphelp_hide_notice_wp_users'); function wphelp_hide_notice_wp_users() { if (!current_user_can( 'manage_options' )) { echo '<style>.update-nag, .updated, .error, .is-dismissible { display: none; }</style>'; } }
Code language: HTML, XML (xml)

Once the changes have been saved, the administrators (manage_options) will see the warnings but not the rest of the users.

With plugins

There are several plugins with which you can achieve this very thing. One of them is Disable WP Notification.

As soon as you activate it you will see a new menu called “Disable Notices” in which you can decide whether to:

  • Leave all notifications active.
  • Disable notifications for all users.
  • Disable notifications for all users except administrators.

It works perfect!

Another one is Hide Dashboard Notifications. Just like the previous one, as soon as you activate it, go to its settings page under “Hide Notices” and there you can decide what to hide:

  • Hide notifications only to administrators.
  • Hide all notices and warnings.
  • Hide WordPress update notices.
  • Hide the PHP update warning.

The notifications will be hidden in the “Notifications” tab in case you want to check them even if they are hidden.

It is a different approach but also interesting.

Let each user decide which notices to hide

The next level would be to allow each user to decide which notices he wants to see and which not.

For this nothing better than the plugin Disable Admin Notices individually.

Once active, in its configuration screen (Settings → Hide Admin Notices) you can choose:

  • Do not hide the notices.
  • Hide all notices.
  • Only the selected ones (those decided by each user, see below).

In addition, you can activate the hidden notices from the WordPress admin bar and, if you need to, reset all notices for you or for all users.

The advantage of this plugin, which differentiates it from the rest, is in the setting to hide only the selected notices.

Once the option is activated and the changes are saved, each user will see in the administration notices a button from which to hide each specific notice for him.

And if, in addition, you have activated the setting to activate the hidden alerts in the administration bar, the user can reactivate the alerts at any time from there.

As you will see it is very complete. It has additional paid options but I think they are unnecessary.

How to create WordPress administration notices

Well, having seen all of the above, you might be wondering, what if I want to create administration notices?

Well, very easy, you can create all kinds of notices, customize them, decide who will see them, everything.

Create administration notices with code

The following example codes of how we can create custom admin prompts you can add them, as always to:

Warning notice on the desktop to all non-dischargeable users

/* Admin notice non-dismissable */ function wphelp_general_notice(){ global $pagenow; if ( $pagenow == 'index.php' ) { echo '<div class="notice notice-warning"> <p>This is a non-dismissable warning notice on the WordPress dashboard.</p> </div>'; } } add_action('admin_notices', 'wphelp_general_notice');
Code language: PHP (php)

To see what you can customize in these codes take a look at these elements:

  • $pagenow == 'admin-page-where-displayed.php'.
  • class="notice notice-warning" – The type of notice, you can change notice-warning to notice-error, notice-success, notice-info.
  • Between the div tags (<div> and </div>) is where the visible text will go.

You get a notice like this:

Error warning in the comment screen for users with author profile and discardable

To see another variation, in this case we are going to make it so that the warning can be dismissed (hidden) by means of a button, that it is an error warning and that only users with an author profile on the comment moderation page see it.

/* Disposable admin notice in the editor to authors */ function wphelp_warning(){ global $pagenow; if ( $pagenow == 'edit-comments.php' ) { $user = wp_get_current_user(); if ( in_array( 'author', (array) $user->roles ) ) { echo '<div class="notice notice-error is-dismissible"> <p>This is a discardable error message to authors in the WordPress editor.</p> </div>'; } } } add_action('admin_notices', 'wphelp_warning');
Code language: PHP (php)

What you get is this notice:

If you review the code, in this case we have changed several things:

  • The visible page ($pagenow) to edit-comments.php.
  • We have added the is-dismissible parameter to the notice class.
  • We added an array to show it only to users with author profile.

These are just a couple of examples, which you can use as a basis for other possible customizations.

Create administration notices with a plugin

If you prefer to use a plugin to create your own custom admin notices the right choice is to use KJM Admin Notices.

When you install and activate this free plugin you will see a new content type called “Notices“, where to create your admin notices.

To make everything easier, the different categories of warnings are already created by default, each one with its characteristic color, as we saw at the beginning of this article:

  • Default – Gray border
  • Info – Blue border
  • Warning – Yellow border
  • Success – green border
  • Error – Red border

But you can customize them or even add new ones, choosing even the color of the border you want.

Once you have the necessary categories (types) of notices, creating new notices is very simple, you only have to add a notice, give it a title, its text, choose the category and define the display settings.

You can decide who will see the notice:

How and what will be visualized:

And, above all, what type (category) it will be:

If you have noticed, there is even some shortcode that you can use to customize your messages.

The plugin even has view statistics, the ability to send email alerts to users, and a setting to display alerts even in the public part of the website.

As you can see, fantastic, it lacks nothing.

Click to rate this post!
[Total: 0 Average: 0]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top Skip to content