For all the WordPress users, it is really annoying when WordPress update notice is displayed on the dashboard if there are any upgrade available for the installed WordPress version. The notice will not clear until the WordPress is upgraded to latest version. Similarly the update notice for installed plugins & themes is displayed on the WordPress dashboard, plugins & themes pages. In this article, I will show you how to disable update notifications for core WordPress as well as for plugins and themes.

The purpose of these errors are to help developers debug issues with their code. Plugin and theme developers need this information to check for compatibility and best practices.

Here few line of code you can easily use to remove those notices.

function dsourc_hide_notices(){
	$user = wp_get_current_user();
	if (!($user->roles[0] == 'administrator')) {
		remove_all_actions( 'admin_notices' );
	}
}
add_action( 'admin_head', 'dsourc_hide_notices', 1 );

Here the steps you can follow to correctly remove other plugin/theme admin notices in your administration panels.

  • Create a Function name as you want
  • fetch Current user whether he is admin or on your custom role user,
  • Detect your admin pages by using “if (!($user->roles[0] == ‘administrator’))” You need to know when to remove the notices and limit that action only to your administration pages. Hence you need a way to determine when the user is looking at your pages, for example looking at the “page” request parameter.
  • Remove all registered admin notice actions WP lets everyone to remove all attached functions to an event, so we can remove all other plugin/theme actions.
  • Add our noticesOnce removed other notices we can add our if needed.