wp2moodle--wordpress-
wp2moodle--wordpress- copied to clipboard
Default enrolment period
Hello, thanks for great work.
I like configure Default enrolment period. It is possible?
Thanks
Hi sorry it's taken a while to get back here - I've been moving house.
When using a courseid or groupid, the user gets enrolled into the course using the first instance of the manual enrolment plugin on the course, so perhaps you could configure that instance to have a default enrol period. Cohort enrolment doesn't have and enrolment period option afaik.
Hello,
I configure the instance, but not work.
To work I add this custom code in login.php after line 136.
$courseId = 0; // cache
//// Extras Variables ////
$courserow = $DB->get_record('course', array('idnumber'=>$course_idnumbers));
$courseId = $courserow->id;
$enrolid = $DB->get_record('enrol', array('courseid'=>$courseId, 'enrol'=>'manual'));
$extendperiod = $enrolid->enrolperiod;
$now = time();
$today = make_timestamp(date('Y', $now), date('m', $now), date('d', $now), date('H', $now), date('i', $now), date('s', $now));
$timestart = $today;
$timeend = $timestart + $extendperiod;
//// End Custom ////
And change this code:
from
if (!enrol_try_internal_enrol($courserow->id, $user->id, $studentrow->id)) {
to
if (!enrol_try_internal_enrol($courserow->id, $user->id, $studentrow->id, $timestart, $timeend)) {
Thanks
Oh right - that looks like a good idea. I'll see if I can put the support in, or get it to inherit those values from the enrolment instance (which I thought it did do - evidently not any more).