global $CFG, $SESSION, $USER, $FULLME, $HTTP_REFERER, $PHPSESSID;
// First check that the user is logged in to the site.
-
if (! (isset($USER->loggedin) and $USER->confirmed and ($USER->site == $CFG->wwwroot)) ) { // They're not
$SESSION->wantsurl = $FULLME;
$SESSION->fromurl = $HTTP_REFERER;
}
die;
}
+
+ // Check that the user account is properly set up
+ if (user_not_fully_set_up($USER)) {
+ $site = get_site();
+ redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
+ die;
+ }
// Next, check if the user can be in a particular course
if ($courseid) {
return update_record("user", $user);
}
+function user_not_fully_set_up($user) {
+ return (empty($user->firstname) or empty($user->lastname) or empty($user->email));
+}
function update_login_count() {
/// Keeps track of login attempts
set_moodle_cookie($USER->username);
-
- if (empty($SESSION->wantsurl)) {
+ if (user_not_fully_set_up($USER)) {
+ $site = get_site();
+ header("Location: $CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
+
+ } else if (empty($SESSION->wantsurl)) {
header("Location: $CFG->wwwroot");
+
} else {
header("Location: $SESSION->wantsurl");
unset($SESSION->wantsurl);