Created
February 1, 2024 22:27
-
-
Save ghwoodard/6b63e97b457c542e2d458b335eaa6c60 to your computer and use it in GitHub Desktop.
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
<?php | |
// Hide Admin Notices | |
function hide_update_msg_non_admins(){ | |
if (current_user_can( 'manage_options' )) { // User Caps | |
echo '<style>#admin-notice { display: none; } .e-notice--dismissible { display: none; }</style>'; | |
} | |
} | |
add_action( 'admin_head', 'hide_update_msg_non_admins'); | |
// Alternate Version - More PHP Focused | |
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are some edits to make these customizable to your needs:
Alternate Version