Created
August 1, 2012 03:26
-
-
Save danpoltawski/3223376 to your computer and use it in GitHub Desktop.
enrol all users to a course
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define('CLI_SCRIPT', true); | |
| require_once('config.php'); | |
| require_once($CFG->dirroot.'/user/lib.php'); | |
| define('COURSEID', 2); | |
| define('STUDENTROLEID', 5); | |
| $enrol = enrol_get_plugin('manual'); | |
| $enrolinstances = enrol_get_instances(COURSEID, true); | |
| $rs = $DB->get_recordset_sql('SELECT id FROM {user} WHERE id > 2'); | |
| foreach ($rs as $r) { | |
| $enrol->enrol_user($enrolinstances[1], $r->id, STUDENTROLEID); | |
| } | |
| $rs->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment