Cara menggunakan hide admin notices wordpress

Skip to content

Table of Contents

  • Post navigation
  • How do I turn off PHP warnings in WordPress?
  • How do I hide warnings and notices in PHP?
  • How do I turn off notices in WordPress?
  • How do I turn off PHP errors?

Cara menggunakan hide admin notices wordpress

AitThemes

Block-based WordPress Theme

PHP Warnings and PHP Notices can come from various plugins and might fill up your error log. You can turn them off in your wp-config.php file with these settings:

ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

Post navigation

Rating: 5.0/5. From 3 votes.

Please wait...

This tutorial will show you how to hide PHP warnings and notices in WordPress.

WordPress. How to hide PHP warnings and notices

For example this warning at the frontend:

  1. Log into the Host Control Panel (Cpanel). Go to File Manager (or you can connect to FTP):

    Get to the root directory of the website, open wp-config.php file:

  2. In this file, we will search for:

     define('WP_DEBUG', false);
    

    We will replace this piece of codes with:

    ini_set('log_errors','On');
    ini_set('display_errors','Off');
    ini_set('error_reporting', E_ALL );
    define('WP_DEBUG', false);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
    

    Save the file.

Refresh the page to check the result.

Feel free to check the detailed video tutorial below:

WordPress. How to hide PHP warnings and notices

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket

How do I turn off PHP warnings in WordPress?

Either way, you're looking for the “WP_DEBUG” portion of the wp-config. php file. Click the “Save Changes” button in the top right. Once the file is saved, this will disable the PHP warnings in WordPress.

How do I hide warnings and notices in PHP?

In the current file, search for the line of code error_reporting. There will be a line of Default Value: E_ALL as shown below: Replace this line of code with Default Value: E_ALL & ~E_NOTICE. It will display all the errors except for the notices.

How do I turn off notices in WordPress?

Installation.

Press the Add New button on your WordPress Dashboard Plugins screen..

Search for “Hide Admin Notices”.

Press Install Now and then Activate..

The plugin will work straight away; there is nothing more to do!.

How do I turn off PHP errors?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet:

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
  • Types of WordPress administration prompts
    • Achievement notice (green border)
    • Warning notice (yellow border)
    • Information notice (blue border)
    • Error notice (red border)
    • WooCommerce notices (purple border)
  • What are management notices useful for?
  • The problem of too many WordPress administration warnings
    • Sales and marketing notices
    • Notices of minor issues
    • Recurrent notices
    • Data tracking notices
  • How to control and hide WordPress administration notices
    • How to completely hide WordPress administration notices
      • With a code
      • With a plugin
    • How to selectively hide WordPress administration notices
      • Hide warnings only to non-administrator users
        • With a code
        • With plugins
      • Let each user decide which notices to hide
  • How to create WordPress administration notices
    • Create administration notices with code
      • Warning notice on the desktop to all non-dischargeable users
      • Error warning in the comment screen for users with author profile and discardable
    • Create administration notices with a plugin

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.

Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

Error notice (red border)

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

Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

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>

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.

Cara menggunakan hide admin notices wordpress

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.
Cara menggunakan hide admin notices wordpress

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.
Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

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:

  • The functions.php file of the active (child) theme.
  • Your own customization plugin.

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 '

This is a non-dismissable warning notice on the WordPress dashboard.

'; } } 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 (
    and
    ) is where the visible text will go.

You get a notice like this:

Cara menggunakan hide admin notices wordpress

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 '

This is a discardable error message to authors in the WordPress editor.

'; } } } add_action('admin_notices', 'wphelp_warning');

Code language: PHP (php)

What you get is this notice:

Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

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
Cara menggunakan hide admin notices wordpress

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:

Cara menggunakan hide admin notices wordpress

How and what will be visualized:

Cara menggunakan hide admin notices wordpress

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

Cara menggunakan hide admin notices wordpress

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.

Cara menggunakan hide admin notices wordpress

As you can see, fantastic, it lacks nothing.