-
Bug
-
Resolution: Won't Fix
-
Minor
-
None
-
2.3.1
-
MOODLE_23_STABLE
I noticed that enrolments with enrolment periods set do not actually get removed once the period has passed. I think the reason this happens is because the cron() function in enrollib.php doesn't actually do anything.
I'm using version 2.2.3, but it seems this function still does nothing in the newer versions of the code I've seen.
Below is the code I'm using to remove expired enrolments:
public function cron() {
global $DB;
// Unenrol course enrolments whose enrolment periods have passed
$sql = "SELECT e.*, ue.userid
FROM
e
JOIN
ue ON (ue.enrolid = e.id)
WHERE ue.timeend < curdate() and ue.timeend != 0";
$rs = $DB->get_recordset_sql($sql);
foreach ($rs as $instance)
$rs->close();
}