Last active
June 27, 2023 03:23
-
-
Save digisavvy/174a8a65accce24d9bc8c8f2441e9bdb to your computer and use it in GitHub Desktop.
hide admin notices in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('admin_enqueue_scripts', 'ds_admin_theme_style'); | |
add_action('login_enqueue_scripts', 'ds_admin_theme_style'); | |
function ds_admin_theme_style() { | |
if (!current_user_can( 'manage_options' )) { | |
echo '<style>.update-nag, .updated, .error, .is-dismissible { display: none; }</style>'; | |
} | |
} |
Works as expected thanks, here is my version. just use in functions file or small plugin.
small plugin: https://github.com/devuri/hide-wp-admin-notices
add_action('admin_enqueue_scripts', function () {
if ( ! current_user_can( 'manage_options' ) ) {
echo '<style>.update-nag, .updated, .error, .is-dismissible { display: none; }</style>';
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Kyzoe,
You could just block it overall in notice by adding the below to the funtion.php file:
{
echo '<style>.wp-core-ui .notice.is-dismissible { display: none; }</style>' ;
}