Skip to content

Instantly share code, notes, and snippets.

@mmarj
Forked from digisavvy/hide-admin-notices.php
Last active January 22, 2021 17:30
Show Gist options
  • Save mmarj/3852da9f999537376540350f59d78157 to your computer and use it in GitHub Desktop.
Save mmarj/3852da9f999537376540350f59d78157 to your computer and use it in GitHub Desktop.
hide admin notices in WordPress.
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>';
}
}
/* Hide wp-admin side notice with CSS */
add_action('admin_head', 'custom_css_on_admin_dashboard');
function custom_css_on_admin_dashboard() {
echo '<style>
.notice, .dokan-license-notice, .update-nag, .updated, .error, .is-dismissible, .elementor-message {
display: none !important;
}
</style>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment