get_userinfo expected result?

Re: get_userinfo expected result?

by Ryan Foster -
Number of replies: 0

As far as I can tell, the Moodle $user_fields array is like this:

Array
(
    [0] => firstname
    [1] => lastname
    [2] => email
    [3] => city
    [4] => country
    [5] => lang
    [6] => description
    [7] => url
    [8] => idnumber
    [9] => institution
    [10] => department
    [11] => phone1
    [12] => phone2
    [13] => address
)

The expected result from get_userinfo would have the values from the above array as keys, and the actual user data as values.  Something like this:

array(4) {
  ["firstname"]=>
  string(12) "Ryan"
  ["lastname"]=>
  string(6) "Foster"
  ["email"]=>
  string(15) "ryan.foster@example.com"
  ["username"]=>
  string(7) "rfoster"
}

Of course, it's been a little while since I did my testing to figure this out, so I may have missed something in my explanation.  I also haven't experimented with any custom profile fields (Moodle 2.6 and up, I think) to see how those come into play.  Hopefully this is helpful for anyone wanting to write an authentication plugin that updates user profile data.