From 012d14e8929454b57add6cc5cfe7bf3ebc85e2a2 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Wed, 23 Sep 2015 09:51:44 +0800 Subject: [PATCH] MDL-50332 enrol_self: Setting form url for guests Credit to Andrew Nicols. --- enrol/self/lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/enrol/self/lib.php b/enrol/self/lib.php index 6dca20b70cf0c..6c1364b4a3b78 100644 --- a/enrol/self/lib.php +++ b/enrol/self/lib.php @@ -249,7 +249,11 @@ public function enrol_page_hook(stdClass $instance) { $data = new stdClass(); $data->header = $this->get_instance_name($instance); $data->info = $enrolstatus; - $form = new enrol_self_empty_form(null, $data); + + // The can_self_enrol call returns a button to the login page if the user is a + // guest, setting the login url to the form if that is the case. + $url = isguestuser() ? get_login_url() : null; + $form = new enrol_self_empty_form($url, $data); } ob_start();