Skip to content

Instantly share code, notes, and snippets.

@michael-milette
Created September 26, 2017 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michael-milette/b84d204b94d213d3b78dc3ae806f4d64 to your computer and use it in GitHub Desktop.
Save michael-milette/b84d204b94d213d3b78dc3ae806f4d64 to your computer and use it in GitHub Desktop.
Get a list of all roles in WordPress and return them as an array.
/*
* Get a list of all roles in WordPress and return them as an array.
* @return array of roles.
*/
function getRolesArray() {
global $wp_roles;
foreach($wp_roles->roles as $key => $role) {
$roles[] = $key;
}
return $roles;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment