How to Add Administration Notifications on WordPress

Do you want to add admin notifications on 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 on 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 may also use 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 may also be useful for multi-author WordPress websites. You can add alerts to guide new authors on how they work.

However, we recommend you to use administrative notices with care. 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: Manually Add Specific Information on WordPress

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 Admin

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>
add_action('admin_notices', 'general_admin_notice');

This code displays a message on the installation page custom admin notice
If you learn about code, you’ll notice that we used the $pagenow variable to determine the current page.

We then add conditions to check if the current page matches the page on which we want to display the message.

If duplicated, we will continue to display the notice in the section <div>. This div section uses the CSS levels that have been formatted in WordPress admin page styles (stylesheet) for different notification types.

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

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

In addition to checking the current page, you can add various types of conditions to display messages that match your requirements.

For example, if you want to display notifications specifically for users with author roles, here’s what you need to do:

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

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

This is how it will appear on your site.

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

Method 2: Add Administration Notifications With Plugin

This method is simpler because it doesn’t 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 the KJM Admin Notices plugin. For more detailed instructions, read our article How to install plugins on WordPress.

After activation, go to Settings »KJM Admin Notices page to set up plugin installation.

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

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

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

Don’t forget to click the save changes button to save your settings.

Now you will 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 the Notices »Add Notice page, you will see a screen quite similar to the article editing screen.

Start by adding the title of the notification, then adding the message text from the article 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 close the notification.

Once done, select the ” publish” button and your admin notification will appear on the site.

KJM Admin Notices allows you to manage your admin notifications without writing any code. You can delete or not post the messages you no longer want to display.

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

If you do not 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 to add administrative messages. Hope this article can help you.

Nulled By __BOSS__

BROTHER OF GPL ------ ------ ------- ------- ------ ----- ------- THE BOSS.

Leave a Reply

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

76 − = 71

Does Shared Hosting affect SEO?

Learn about files and directory structure in WordPress