There is an API available to ADD a user to an existing course

There is an API available to ADD a user to an existing course

by Haik KHATCHATRIAN -
Number of replies: 3

Hello,

I want to know if there are existant function to add user to existing course ?

Thank in advance.

Average of ratings: -
In reply to Haik KHATCHATRIAN

Re: There is an API available to ADD a user to an existing course

by Krishna Mohan Prasad -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Haik KHATCHATRIAN,

I hope you are talking about enrolling users into existing course. 

Enrolment is handled by different enrolment plugins that you make available in course. 

To find available enrolment methods you can use core_enrol_get_course_enrolment_methods  API. After this you can enrol users using one out of these available enrolment methods using their enrol_user method. You can find some useful references inside enrollib.php in enrol_plugin class, and inside lib.php files of enrolment plugins.


Thanks

In reply to Haik KHATCHATRIAN

Ri: There is an API available to ADD a user to an existing course

by Nicola Vallinoto -
Hi Haik,
I've used the enrol_manual_enrol_users api function.
The parameters are: userid, courseid and roleid.
Nicola
Average of ratings: Useful (1)
In reply to Nicola Vallinoto

Re: Ri: There is an API available to ADD a user to an existing course

by Haik KHATCHATRIAN -
Hi Nicola,

I currently use this function, and it works, thank you for your help.

Haik