moodle 2 & 3: exclude my-moodle from admin

November 16, 2014

updated 2017-02-04

How to exclude admin, administrators, from the my-moodle dashboard

The moodle Administrator is no longer excluded from the my-moodle module.

Starting with moodle 2.0, if we activate the my-moodle front page for students, administrators get thrown into it also upon logging in.

in ~/moodle199/index.php you could turn on "MyMoodle" for users and there was an exception
for administrators, that exception has been "lost" in moodle 2.0.x onward.

to fix it, reinstate it, edit the primary index.php {moodle}/index.php

moodle 2.x

down around line 70, find

} else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY)
&& optional_param('redirect', 1, PARAM_BOOL) === 1 ) {
redirect($CFG->wwwroot .'/my/');

and insert 2 carriage returns (to break it up)
and insert "&& !$hassiteconfig"
because the site configuration authority is only for admen. and this excludes them.

} else if (!empty($CFG->defaulthomepage)
&& ($CFG->defaulthomepage == HOMEPAGE_MY)
&& optional_param('redirect', 1, PARAM_BOOL) === 1
&& !$hassiteconfig ) {
redirect($CFG->wwwroot .'/my/');

note that you are inserting your new && clause right before the last 2 characters, the closing parenthesis and the opening bracket.

moodle 3.x

down around line 71, find

} else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY)
&& $redirect === 1 ) {

and insert 2 carriage returns (to break it up)
and insert "&& !$hassiteconfig"
because the site configuration authority is only for admen. and this excludes them.

} else if (!empty($CFG->defaulthomepage)
&& ($CFG->defaulthomepage == HOMEPAGE_MY)
&& $redirect === 1
&& !$hassiteconfig ) {
redirect($CFG->wwwroot .'/my/');

Again, the site configuration authority is only for admen. and this excludes them.

Leave a Reply

Your email address will not be published. Required fields are marked *

We try to post all comments within 1 business day