是否有办法获得所有角色,包括(id和rolename)
function getrole {
$options = array();
foreach (role_get_names() as $myrole) {
$options[$myrole->id] = $myrole->localname;
}
return html_writer::select($options);
}
// The true at the end is used to return an array for select elements.
// So this returns an array with array(roleid => 'originalrolename')
$options = role_fix_names(get_all_roles(), context_system::instance(), ROLENAME_ORIGINAL, true);