How to disable Admin Notices in WordPress

  • 21 February, 2019
  • 2

How to disable Admin Notices in WordPress

We as a WordPress designer and developer have faced many problems while using the third party plugins and themes like unnecessary admin notices and we are going to disable admin notices . The annoying notices displays and we want to get rid of it. 

Disable admin notice in wordpress

WordPress is nothing without plugins. While we have to do from scratch it takes lots of time and pressure. What can be done by simply installing plugins it might take days or even weeks while doing from the scratch or coding in WordPress too. But sometimes we might get the result we want but the annoying admin notices might be the hectic. In that case some of us might uninstall the plugins and search for the alternatives without knowing we can disable admin notices

In this post, we’ll be discussing how to disable admin notices WordPress admin area.

Thanks to the WordPress team that has developed the hooks. With the help of the simple action and filters we can disable admin notices.

Just put the following code in your themes function file.

function pr_disable_admin_notices() {
		global $wp_filter;
			if ( is_user_admin() ) {
				if ( isset( $wp_filter['user_admin_notices'] ) ) {
								unset( $wp_filter['user_admin_notices'] );
				}
			} elseif ( isset( $wp_filter['admin_notices'] ) ) {
						unset( $wp_filter['admin_notices'] );
			}
			if ( isset( $wp_filter['all_admin_notices'] ) ) {
						unset( $wp_filter['all_admin_notices'] );
			}
	}
add_action( 'admin_print_scripts', 'pr_disable_admin_notices' );

Code description: I think I don’t have to describe each and every line of the code here. I will shortly describe what we have done in the above code. We have defined one function named pr_disable_admin_notices. And inside this function we have checked if the user is admin or not in line 3 . If the logged in user is admin we have simply unset all the notices. Here we have disable three notices: 1. user admin notices 2. admin notices and 3. all admin notices. In the last or 14th line we have call back function which we have created in the first line.

You might be interested in this topic as well:
1. BEST SEO PLUGINS FOR WORDPRESS WEBSITES
2. HOW TO DOWNLOAD SHUTTERSTOCK IMAGES FOR FREE?
3. FREE WEB DESIGN RESOURCES WEBSITE TO BOOKMARK

Didn't find what you came for?

Don't be sad. We are here for your help. Just request a quote and we will come up for your solution.