Adding Custom Admin Notices in WordPress Dashboard

Want create site? Find Free WordPress Themes and plugins.

In the article below , we will show your group below  to add admin notice in wordpress.Where to use admin notices in wordpress. Admin notices are used in wordpress to alert uses about errors, warning of succes

s messages.

Admin notice are also used by individuals site owners, plugin authors of them developers.

You can also add admin notices to display helpful information across wordpress admin area for such website client who is not familiar with wordpress.

If you are running a multi-author wordpress site, you can use custom admin notices them. Notices can added for guiding new authors of helping them finding their way around.

Beside this, Admin notices should be used carefully as they may rain wordpress experience for your users.

There are some methods through which you can add your own custom admin notices in wordpress.


Custom Notices should be added in wordpress manually.

In this method code should be added to your word press site.

First of all you will be needed to add this code to your themes function php file or a site-specific plugin.

  1. Function general-admin-notice( ) {
  2. Global $pagenow;
  3. If ( $pagenow ==’option-general. php’) {
  4. Echo’ <div class=”notice notice-warning is – dismissible “>
  5. <p> This notice appears on the settings page. </p>
  6. </div>’;
  7. }
  8. }
  9. Add-action (‘admin-notices’, ‘general-admin-notice’);

A notice will be displayed with a yellow border and a button on it in order to close it on the settings page.

general settings

After studding the code, it will be noticed that $pagenow  variable is used in order to defect the current page.

Condition is added that checks that where the current page meets the playing page or not. if it does, then the notice is shown wrapped in a <div> element. This div element uses CSS classes.

You can may add notice- error, notice-warning, notice success or notice into but for this you would first be needed to use notice class. Is- dismissible class can also be used optionally.

Beside there checking  the current page, all kinds of condition can also be added in order to show notices matching different scenarios.

For instance, you want that a notice should be displayed only to users with the author user role. i.e

  1. Function author- admin –notice( ){
  2. Global $pagenow;
  3. If ($pagenow==’index. Php’){
  4. $user=wp_get_current_user( );
  5. If (in _array (‘auther’,(array)$user_>roles)){
  6. Echo'<div class=”notice notice_info is_dismissible”>
  7. <p>click on <a href=”edit.php”>posts</a> to start writing. </P>.
  8. </div>’;
  9. }
  10. }
  11. }
  12. Add_action (‘admin_notice’, ‘author_admin_notice’);


2nd Method:

In this method admin notice are added using a wordpress plugin.

This 2nd method is much simpler than that of above one there is no need to add code in this method but beside this it is less flexible than that of custom code method.

First of all you would be needed to install and activate the KJM admin Notice plugin.

while activating , you would be needed to visit settings >> KJM admin notice page to configure plugin settings.

KJM Admin Notices Settings


You would first be needed to check the option in order to enable KJM admin notices. In the second option a custom post type is added in order to add and edit  your custom admin notices.

The plugin helps you in sending an email to registered users. For enabling this feature the box next to send Email option is checked.


Click on the save changes button in order to save your settings.

Now you will see a new menu item labeled notice in your wordpress admin bar. There you can add or edit your custom admin notices.

For instance lets create your first admin notice.

First you will visit Notices >> Add Notice page, there you will see a screen much that would look like the wordpress post edit screen.


Then take a start by adding a title for notice and after doing it you would add the actual notice in the post editor. Now you may select the notice category from the box on your right hand. Now it’s the time that you would be needed to select the user roles which will see this notice.

Title can be optionally shown or hided as well as author date and the button to dismiss notice.

Now you are ready to click on the publish button for living your custom admin Notice.

Through email features, all of your users would be alerted either they log into the check notice or not.

Did you find apk for android? You can find new Free Android Games and apps.

About Author

Leave A Reply