Retrieve an array of roles matching specified conditions.
$membersonly: Set this to TRUE to exclude the 'anonymous' role.
$permission: A string containing a permission. If set, only roles containing that permission are returned.
An associative array with the role id as the key and the role name as value.
function user_role_names($membersonly = FALSE, $permission = NULL) {
return array_map(function ($item) {
return $item
->label();
}, user_roles($membersonly, $permission));
}