Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
Created May 17, 2022 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfsarmento/0f10697f99da53a36fc9e845a67f4ac7 to your computer and use it in GitHub Desktop.
Save nfsarmento/0f10697f99da53a36fc9e845a67f4ac7 to your computer and use it in GitHub Desktop.
Disable admin notices In WordPress for all users apart from the the ID define on the Array
<?php
/**
* How To Disable Admin Notices In WordPress
*
*/
add_action('admin_enqueue_scripts', 'os_admin_theme_style');
add_action('login_enqueue_scripts', 'os_admin_theme_style');
function os_admin_theme_style() {
$super_admins = array( 5 );
if( ! in_array( get_current_user_id(), $super_admins ) ){
echo '<style>.update-nag, .updated, .error, .is-dismissible, .notice-warning, .notice { display: none !important; }</style>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment