Created
February 20, 2019 11:36
-
-
Save plugin-republic/0994f23eeaf37fdcace6f87f510594ca to your computer and use it in GitHub Desktop.
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 the user's roles | |
* @since 1.0.0 | |
*/ | |
function wcmo_get_current_user_roles() { | |
if( is_user_logged_in() ) { | |
$user = wp_get_current_user(); | |
$roles = ( array ) $user->roles; | |
return $roles; // This returns an array | |
// Use this to return a single value | |
// return $roles[0]; | |
} else { | |
return array(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment