Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during self-enrollment if assigned role does not have roleid=5. #118

Open
spunkt1 opened this issue Sep 30, 2024 · 0 comments
Open

Comments

@spunkt1
Copy link

spunkt1 commented Sep 30, 2024

Hi,

If a course is created with self-enrollment and the participant role does not have rolid = 5, or a different role has been configured for self-enrollment, then a user can enroll in the course, but no role is assigned.

In the file “moodle/admin/tool/supporter/classes/external.php” the roleid “5” is hard-coded

$plugin->add_instance($createdcourse, [“password” => $selfenrolpassword, “roleid” => 5]);

Here is a suggestion on how to change this.
Instead of the “5”, the default role from “Enrol” should be used.

$selfenrolment = $DB->get_record(“enrol”, ['courseid' => $createdcourse->id, 'enrol' => 'self'], '*');
$plugin->add_instance($createdcourse, ['password' => $selfenrolpassword, 'roleid' => $defaulSelfenrolRoleid]);

Best regards,
Sybille

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant