Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Add Custom Admin Notices in WordPress

Do you want to add custom admin notices in WordPress?

Admin notices are used by WordPress core, themes, and plugins to display errors, warnings, notices, and important on-screen information to users.

In this article, we will show you how you can easily add custom admin notices in WordPress.

Adding custom admin notifications in WordPress

Why and When to Use Admin Notices in WordPress?

WordPress comes with a built-in system to display notifications inside the WordPress admin area.

These admin notices allow developers to display errors, warnings, alerts, or success messages on-screen.

Individual site owners, plugin authors, and theme developers can also use admin notices for a better user experience.

Admin notice example

For instance, if you are working on a WordPress website for clients who are not familiar with WordPress, then you can add admin notices to display helpful information across their WordPress admin area.

Custom admin notices can also be helpful if you run a multi-author WordPress site. You can add notices to guide new authors and help them find their way around.

However, we recommend using admin notices carefully. Too many notices or unhelpful notices can be annoying and may ruin the WordPress experience for your users.

Having said that, let’s take a look at how you can add your own custom admin notices in WordPress.

Method 1. Quickly Display Custom Admin Notice in WordPress

This method is easier and recommended for non-developer users who only need to display one custom admin notice to all logged-in users inside the WordPress admin area.

First, you need to install and activate the Admin Notice plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit the Settings » Admin Notice page to create your custom admin notice.

From here, you need to check the Enable option and then write down your custom notice. You can use the formatting toolbar to format your notice.

Add your custom admin notice

Below that you can choose the notice style next to the Style option. The plugin allows you to display admin notice as an error, info, success, or warning notice type.

Once you are finished, you can simply click on the Save button to store your custom admin notice.

The plugin will immediately start displaying your custom admin notice to all logged-in users who can access the WordPress admin area.

Custom admin notice displayed

Note: The plugin only allows you to add one custom notice at a time and you cannot choose which logged-in users will see the notice.

If you need more flexibility, then the following method allows you to create more targeted custom admin notices in WordPress.

Method 2. Create Custom Admin Notices in WordPress Manually

This method requires you to add code to your WordPress website. If you haven’t done this before, then please take a look at our guide on how to copy and paste code in WordPress.

We’ll start by creating a generic notice that will be displayed for all users on all admin pages.

Simply copy and paste the following code to your theme’s functions.php file or a site-specific plugin.

function wpb_admin_notice_warn() {
echo '<div class="notice notice-warning is-dismissible">
      <p>Important: we will not be publishing any new articles during holidays. Please save your articles as drafts for the time being.</p>
add_action( 'admin_notices', 'wpb_admin_notice_warn' );

This code simply displays the HTML required to display an admin notice.

The admin notices need to wrapped inside a div element with the notice CSS class. After that, we’ll add the CSS class for the type of admin notice. WordPress accepts the following notice type classes

  • notice-warning
  • notice-error
  • notice-info
  • notice-success

Lastly, we added an optional CSS class is-dismissable which will tell WordPress to display a close button for this admin notice.

Don’t forget to save your changes and visit your WordPress admin area dashboard. You’ll see your custom admin notice displayed on the screen.

Admin notice preview

Now, let’s see how to make our custom notice more targeted.

To do this, you’ll need to some knowledge of WordPress functions, conditional tags, filters, and hooks.

Let’s create a custom notice that is only displayed to users with the author user role.

function wpb_author_admin_notice(){
    global $pagenow;
    if ( $pagenow == 'index.php' ) {
    $user = wp_get_current_user();
    if ( in_array( 'author', (array) $user->roles ) ) {
    echo '<div class="notice notice-info is-dismissible">
          <p>Click on <a href="edit.php">Posts</a> to start writing.</p>
add_action('admin_notices', 'wpb_author_admin_notice');

This code first checks if the Dashboard page is displayed and the logged in user has author user role. After that, it displays a custom notice message.

Here is how it looked on our test website.

Author only notice

We hope this article helped you learn how to easily add custom admin notices in WordPress. You may also want to see our guide on how to send a custom welcome email to new users in WordPress or take a look at how to show personalized content to different users in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

3 CommentsLeave a Reply

  1. Great article in 2022 as well.. Thanks!
    For those who further want to stylize these admin notices, don’t forget that you need to target the admin page’s own html head element. The proper hook name for that is: ‘admin_head’ . There you can echo your style-s.

  2. Hey, many thanks for your article about Admin Notices, this is really appreciated!

  3. My one posting had been fixed on selected condition with a video from 23rd Sept 2016. Neither it is being possible to edit nor delete.

    Please hepp me to delete that posting.

    With thanks,
    Aegis Mookherji

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.