if ($form = data_submitted()) {
- check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
+ if (empty($course)) {
+ check_for_restricted_user($USER->username, "$CFG->wwwroot");
+ } else {
+ check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
+ }
$form->startdate = make_timestamp($form->startyear, $form->startmonth, $form->startday);