Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38136

2.4 - user_get_user_details doesn't return idnumber

XMLWordPrintable

    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • Hide

      Search for showuseridentity in the admin and enable all fields
      Create a student (in the script it's id = 3, you need to change for the correct id) - fill up all the showuseridentity fields.
      Create a manager
      Connect as manager

      Script to run:

        1 <?php
        2 require_once("./config.php");
        3 require_once("./user/lib.php");
        4 $user = $DB->get_record('user', array('id' => 3));
        5 $userdetails = user_get_user_details($user);
        7 print_r($userdetails);
      

      Run this script without the patch, you should not see idnumber, institution, department. Run the script with the patch, you should see them. Check that showuseridentityfields configuration is respected (following if you disable or enable some of them).

      Show
      Search for showuseridentity in the admin and enable all fields Create a student (in the script it's id = 3, you need to change for the correct id) - fill up all the showuseridentity fields. Create a manager Connect as manager Script to run: 1 <?php 2 require_once("./config.php"); 3 require_once("./user/lib.php"); 4 $user = $DB->get_record('user', array('id' => 3)); 5 $userdetails = user_get_user_details($user); 7 print_r($userdetails); Run this script without the patch, you should not see idnumber, institution, department. Run the script with the patch, you should see them. Check that showuseridentityfields configuration is respected (following if you disable or enable some of them).

      It seems that its not working anymore on 2.4.
      At user/lib.php , line 240 we have

      $showuseridentityfields = get_extra_user_fields($context);

      That is an array of fields, but at line 240 the condition tests if the field is a key

      if ($isadmin or $currentuser or isset($showuseridentityfields['idnumber']))

      when it should test if the value exist in array

      if ($isadmin or $currentuser or in_array('idnumber', $showuseridentityfields))

      Same thing happens for institution, department, phone1 and phone2

            jerome Jérôme Mouneyrac
            danielneis Daniel Neis Araujo
            Damyon Wiese Damyon Wiese
            David Monllaó David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.