mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Admin role assignment: changed from using get_string (too brittle) to
get_roles_with_capability (more robust).
This commit is contained in:
parent
abd896a114
commit
df9c66776d
@ -55,8 +55,12 @@
|
||||
|
||||
|
||||
// Assign the default admin role to the new user.
|
||||
$adminrole = get_record('role', 'name', get_string('administrator'));
|
||||
role_assign($adminrole->id, $user->id, 0, $context->id);
|
||||
if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
|
||||
error('No admin role could be found');
|
||||
}
|
||||
foreach ($adminroles as $adminrole) {
|
||||
role_assign($adminrole->id, $user->id, 0, $context->id);
|
||||
}
|
||||
set_config('rolesactive', 1);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user