Hi Necy, maybe I wasn't too clear above: if you comment out various conditional sections of code in the manual/enrol.php (still assuming you're using the default enrolment method - you have to use something) as pasted here, then your users won't see the enrol.php page but will go straight through to the course/view.php?id=nn [or other requested page]
NB this is still a hack: the cleaner way would be to define a require_enrol_confirmation flag for setting on the Admin page (or even course by course) - I guess I can do this is there's demand for it...
/// Automatically enrol into courses without password
if ($course->password == "") { // no password, so enrol
if (isguest()) {
add_to_log($course->id, "course", "guest", "view.php?id=$course->id", "$USER->id");
}
// TD - aug 2006 - sections below commented out so as to skip
// the ' Are you sure you want to enrol' page
/* else if (empty($_GET['confirm']) && empty($_GET['cancel'])) {
print_header($strloginto, $course->fullname, "<a href=\".\">$strcourses</a> -> $strloginto");
echo "<br />";
notice_yesno(get_string("enrolmentconfirmation"), "enrol.php?id=$course->id&confirm=1", "enrol.php?id=$course->id&cancel=1");
print_footer();
exit;
} */
//elseif (!empty($_GET['confirm'])) {
else {
if ($course->enrolperiod) {
$timestart = time();
$timeend = time() + $course->enrolperiod;
} else {
$timestart = $timeend = 0;
}
if (! enrol_student($USER->id, $course->id, $timestart, $timeend, 'manual')) {
error("An error occurred while trying to enrol you.");
}
$subject = get_string("welcometocourse", "", $course->fullname);
$a->coursename = $course->fullname;
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id";
$message = get_string("welcometocoursetext", "", $a);
if (! $teacher = get_teacher($course->id)) {
$teacher = get_admin();
}
email_to_user($USER, $teacher, $subject, $message);
add_to_log($course->id, "course", "enrol", "view.php?id=$course->id", "$USER->id");
$USER->student[$course->id] = true;
if ($SESSION->wantsurl) {
$destination = $SESSION->wantsurl;
unset($SESSION->wantsurl);
} else {
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
}
redirect($destination);
}
/*elseif (!empty($_GET['cancel'])) {
unset($SESSION->wantsurl);
redirect($CFG->wwwroot);
}
*/
}