Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created February 20, 2019 11:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plugin-republic/0994f23eeaf37fdcace6f87f510594ca to your computer and use it in GitHub Desktop.
Save plugin-republic/0994f23eeaf37fdcace6f87f510594ca to your computer and use it in GitHub Desktop.
<?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