diff --git a/lib/accesslib.php b/lib/accesslib.php index 16c712c4694..b819cdb1c58 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1570,7 +1570,10 @@ function compact_rdefs(&$rdefs) { /** * A convenience function to completely load all the capabilities - * for the current user. This is what gets called from login, for example. + * for the current user. This is what gets called from complete_user_login() + * for example. Call it only _after_ you've setup $USER and called + * check_enrolment_plugins(); + * */ function load_all_capabilities() { global $USER, $CFG, $DIRTYCONTEXTS; @@ -1588,8 +1591,6 @@ function load_all_capabilities() { } else if (isloggedin()) { - check_enrolment_plugins($USER); - $accessdata = get_user_access_sitewide($USER->id); // diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a218bac7d58..2d00b35cf93 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3039,6 +3039,9 @@ function complete_user_login($user) { } set_login_session_preferences(); + // Call enrolment plugins + check_enrolment_plugins($user); + /// This is what lets the user do anything on the site :-) load_all_capabilities();