create_new_user() can now import other fields from an external source
authormoodler <moodler>
Sat, 5 Oct 2002 16:49:42 +0000 (16:49 +0000)
committermoodler <moodler>
Sat, 5 Oct 2002 16:49:42 +0000 (16:49 +0000)
if the function for it has been defined.  (Petri's code with additions by me)

lib/moodlelib.php

index f33f887c2d3c44c27814d441780830e20e620f70..a6802bbd72adf25cfd9fe484ad9454bbf736b22c 100644 (file)
@@ -1234,7 +1234,15 @@ function save_session($VAR) {
 
 function create_user_record($username, $password) {
 // Creates a bare-bones user record 
-    global $REMOTE_ADDR;
+    global $REMOTE_ADDR, $CFG;
+
+    if ($CFG->auth_update_userinfo and function_exists(auth_get_userinfo)) {
+        if ($newinfo = auth_get_userinfo($username)) {
+            foreach ($newinfo as $key=>$value){
+                $newuser->$key = $value;
+            }
+        }
+    }
 
     $newuser->username = $username;
     $newuser->password = md5($password);
@@ -1262,7 +1270,7 @@ function authenticate_user_login($username, $password) {
         $CFG->auth = "email";    // Default authentication module
     }
 
-    require("$CFG->dirroot/auth/$CFG->auth/lib.php");
+    require_once("$CFG->dirroot/auth/$CFG->auth/lib.php");
 
     if (auth_user_login($username, $password)) {  // Successful authentication