Last active
June 15, 2020 23:37
-
-
Save utkrishta/d5b7d5a5cc90f59d8e078d4a509016af to your computer and use it in GitHub Desktop.
Add CLASS to admin body if user is not an Administrator
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 | |
//Add class to admin body if user is not an Administrator | |
if( ! current_user_can('administrator') ) { | |
add_filter( 'admin_body_class', 'rw_admin_only_body_class' ); | |
function rw_admin_only_body_class( $classes ) | |
{ | |
$classes = 'admin-readonly'; | |
return $classes; | |
} | |
} | |
/* | |
* This function can be particularly useful when you don't other users except Administrator to make changes to given fields | |
* ie make those fields "read-only" or "hidden" for other users | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment