What are the PHP functions to add/remove a course for a user?

Re: What are the PHP functions to add/remove a course for a user?

by Tim Hunt -
Number of replies: 0
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The way to answer this sort of question for your self is as follows:

1. How do you do this using the Moodle interface?

(Answer, you click on the Assign Roles link in the course admin block, then choose a role to assign.)

2. So, which PHP script is involved?

(Looking in the URL bar, we see that the assign roles UI is admin/roles/assign.php?roleid=5&contextid=..., that is http://cvs.moodle.org/moodle/admin/roles/assign.php?view=markup&pathrev=MOODLE_19_STABLE)

3. Looking at that code, which function does it call?

(Answer: somewhere under the // Process incoming role assignment comment, there is a call to role_assign.)