Created
September 29, 2021 09:00
-
-
Save mehul0810/c725661bb936cd0f94a13232e46e1475 to your computer and use it in GitHub Desktop.
Get user role of the logged in user
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
<?php | |
/** | |
* Get User Role. | |
* | |
* This function can be used to get user role of a loggedin user. | |
* | |
* @since 1.0.0 | |
* | |
* @return string | |
*/ | |
function get_user_role() { | |
global $current_user; | |
$user_roles = $current_user->roles; | |
return array_shift( $user_roles ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment