Invalid enrol context

Invalid enrol context

by Zoran Jančić -
Number of replies: 2
Picture of Particularly helpful Moodlers

I found great little function for enrolling User to a course here: https://moodle.org/mod/forum/discuss.php?d=266496

The problem is, I'm keep getting "invalid enrol instance" error message at the following line:

$enrol->enrol_user($instance, $userid, $roleid);

Stack trace is the following:

invalid enrol instance!' in enrollib.php:1641
enrol_plugin->enrol_user(Object(stdClass), '192', '5')
check_enrol('TT001', '192', '5', 'manual')

Moodle version is 3.3

Average of ratings: -
In reply to Zoran Jančić

Re: Invalid enrol context

by Darko Miletić -

That error means that you tried to enrol user using one enrollment plugin with instance created by another enrollment plugin.


In reply to Darko Miletić

Re: Invalid enrol context

by ivan Rivas -

How can I solve this error? I am using the function to register a student and I get the error