Skip to content
Home » How to Add Administration Notifications on WordPress

How to Add Administration Notifications on WordPress

 

Do you want to add admin notifications to WordPress? Admin notifications are used by WordPress themes or plugins to display alerts, notifications as well as important information to users on the screen. In this article, we will show you how to add admin notifications to WordPress.

Why and When to Use Notifications on WordPress?

WordPress uses admin notifications to notify users about errors, warnings, and success messages.

Website administrators, plugin authors, or interface developers can also access administrative information.

If you are working on a website for customers who are not familiar with WordPress, you can add admin information to display useful information in the WordPress admin section.

Private admin notices can also be useful for multi-author WordPress websites. You can add alerts to guide new writers on how to work.

However, we recommend that you use administrative notifications with caution. They can be quite annoying and ruin the user experience.

As mentioned, let’s see how you can add your own admin notification to WordPress.

Method 1: Add Specific Info to WordPress Manually

This method requires you to add a piece of code to your WordPress site. If you haven’t already, check out our guide to 10 Code Funtions.php for Managing WordPress Admins

let’s get started.

First, you need to add this code to the functions.php interface file or plugin.

function general_admin_notice(){
global $pagenow;
if ( $pagenow == 'options-general.php' ) {
echo '<div class="notice notice-warning is-dismissible">
<p>This notice appears on the settings page.</p>
</div>';
}
}
add_action('admin_notices', 'general_admin_notice');

This code displays a message on the installation page Custom admin notification message
If you learn about the code, you will see that we have used the $pagenow variable to determine the current page.

Then we add conditions to check if the current page matches the page we want to display the message on.

If duplicated, we

Will continue to display notices in the section. This div section uses CSS levels that are formatted in the WordPress admin page style (stylesheet) for the various notification types.

You can use notification levels and then add errors, warnings, successes, or information.

You can also use ‘removable’ levels if you want to add a button to turn off the notification.

In addition to checking the current page, you can add a variety of conditions to display messages that match your needs.

For example, if you want to display notifications specifically for users with the author role, you need to:

function 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>
</div>';
}
}
}
add_action('admin_notices', 'author_admin_notice');

As you can see, we have added another test level to browse user roles in the ministry section

It will look like this on your site.

Feel free to use different filter conditions and features to test admin notifications.

Method 2: Add Administration Notifications with the Plugin

This method is simple as it does not require you to use code. However, it is not as flexible as the above method.

The first thing you need to do is install and activate KJM Admin Notice Plugin. For more detailed instructions, read our article How to Install Plugins on WordPress.

After activation, go to Settings » KJM Admin Notice Page for setting up the plugin installation.

First of all, you need to check the option to enable KJM admin notification. The second option adds a different article format so you can add and customize your admin information.

The plugin also allows you to send an email to registered users when you post a new notification. If you want to use this feature you can check the box next to the ‘Send email’ option.

You can also enable comments for notifications so that users can respond to notifications by commenting. To enable this feature, check the box next to ‘.Allow comments the option.

Don’t forget to click on the Save Changes button to save your settings.

You will now see a new menu item labeled Notification in your WordPress admin bar. This is where you can add and edit your admin notifications.

Try creating your first admin notification.

go to Notices » Add Notifications Page, you will see a screen similar to the article editing screen.

Start by adding the title of the notification, then adding the message text from the text editor. You can choose to categorize notifications from the box on your right.

Next, you need to select the user role to identify who can see this message.

You can optionally hide or show the title, author, date, and even buttons to turn off the notification.

Once done, select the “Publish” button and your admin information will appear on the site.

KJM Admin Notice Notice Allows you to manage your admin notifications without writing any code. You can delete or post messages that you no longer want to be displayed.

By using the email feature, you can also notify all users if they are not logged in to view these notifications.

If you don’t know how to create email notifications? See our guide on how to create email notifications on WordPress

If you also want to take a closer look at the WP Notification Center plugin, it has a Facebook-like notification center on WordPress. Users can select the notification icon to view their notifications.

Thus, I have completed the presentation of 2 methods for adding administrative messages. Hope this article can help you.

Leave a Reply

Your email address will not be published.