Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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