diff --git a/lang/en/my.php b/lang/en/my.php
index bf68e10ef2c..6df0184977d 100644
--- a/lang/en/my.php
+++ b/lang/en/my.php
@@ -4,6 +4,7 @@
$string['mymoodle'] = 'My moodle';
$string['nocourses'] = 'No course information to show.';
+$string['noguest'] = 'The \'My Moodle\' page is not available to guest users';
$string['pinblocks'] = 'Configure pinned blocks for my moodle';
$string['pinblocksexplan'] = 'Any block settings you configure here will be visible (and non-editable) for any user of moodle on their \'my moodle\' screen.';
?>
\ No newline at end of file
diff --git a/my/index.php b/my/index.php
index 5f74feb82ad..3d1e7d3a3e0 100644
--- a/my/index.php
+++ b/my/index.php
@@ -8,6 +8,22 @@
require_login();
+ $mymoodlestr = get_string('mymoodle','my');
+
+ if (isguest()) {
+ $wwwroot = $CFG->wwwroot.'/login/index.php';
+ if (!empty($CFG->loginhttps)) {
+ $wwwroot = str_replace('http','https', $wwwroot);
+ }
+
+ print_header($mymoodlestr);
+ notice_yesno(get_string('noguest', 'my').'
'.get_string('liketologin'),
+ $wwwroot, $_SERVER['HTTP_REFERER']);
+ print_footer();
+ die();
+ }
+
+
$edit = optional_param('edit', '');
$blockaction = optional_param('blockaction');
@@ -23,7 +39,7 @@
}
}
- $PAGE->print_header(get_string('mymoodle','my'));
+ $PAGE->print_header($mymoodlestr);
echo '