function roleassign_get_unassignable_roles in RoleAssign 8
Helper function to get unassignable roles.
Get a list of roles that are not assignable by a restricted user that only has "assign roles" permission, not "administer permissions".
1 call to roleassign_get_unassignable_roles()
- roleassign_user_presave in ./
roleassign.module - Implements hook_ENTITY_TYPE_presave() as hook_user_presave().
File
- ./
roleassign.module, line 198 - Allows site administrators to delegate the task of managing user's roles.
Code
function roleassign_get_unassignable_roles() {
$all_roles = user_role_names(TRUE);
// Ignore Authenticated user as this is not required.
unset($all_roles[RoleInterface::AUTHENTICATED_ID]);
$assignable_roles = array_filter(\Drupal::config('roleassign.settings')
->get('roleassign_roles'));
$unassignable_roles = array_diff(array_keys($all_roles), $assignable_roles);
return $unassignable_roles;
}