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

After upgrading to 4.1, the client is not redirected to /user/edit.php if a mandatory custom field is not filled in

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • None
    • 4.1.4
    • User management
    • None
    • MOODLE_401_STABLE

      After upgrading to Moodle 4.1 from 3.9, if the user has a missing required custom field in the table

      user_info_data
      

      The client is not redirected to the profile edit page, like it used to be in previous verisons.

      The relevant code in the user/profile/lib.php file, should be this

      /**
       * Does the user have all required custom fields set?
       *
       * Internal, to be exclusively used by {@link user_not_fully_set_up()} only.
       *
       * Note that if users have no way to fill a required field via editing their
       * profiles (e.g. the field is not visible or it is locked), we still return true.
       * So this is actually checking if we should redirect the user to edit their
       * profile, rather than whether there is a value in the database.
       *
       * @param int $userid
       * @return bool
       */
      function profile_has_required_custom_fields_set($userid) {
          $profilefields = profile_get_user_fields_with_data($userid);
          foreach ($profilefields as $profilefield) {
              if ($profilefield->is_required() && !$profilefield->is_locked() &&
                  $profilefield->is_empty() && $profilefield->get_field_config_for_external()['visible']) {
                  return false;
              }
          }
       
          return true;
      }
      
      

      The old one was:

      function profile_has_required_custom_fields_set($userid) {
          global $DB;
       
          $sql = "SELECT f.id
                    FROM {user_info_field} f
               LEFT JOIN {user_info_data} d ON (d.fieldid = f.id AND d.userid = ?)
                   WHERE f.required = 1 AND f.visible > 0 AND f.locked = 0 AND d.id IS NULL";
       
          if ($DB->record_exists_sql($sql, [$userid])) {
              return false;
          }
       
          return true;
      }
      
      

            Unassigned Unassigned
            a.orsini Andrea
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

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