-
-
Save cloudcreatordotio/f8cb9cc23004e76bea29c5a5bf032e96 to your computer and use it in GitHub Desktop.
WordPress: Check if user role exists
This file contains hidden or 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
function role_exists( $role ) { | |
if( ! empty( $role ) ) { | |
return $GLOBALS['wp_roles']->is_role( $role ); | |
} | |
return false; | |
} |
This file contains hidden or 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
if( role_exists( 'editor' ) ) { | |
// The 'editor' role exists! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment