I was looking to start using Moodle's existing webservices to create new users from an external source, but I noticed that the core_user webservices are missing several fields for users, including phone1, institution, department, and maildisplay. Maybe one of the core developers could weigh in here, are there any plans to add these fields in? If there's not a lot of bandwidth among the core developers to do this right now, would you accept pull requests for these additions?
core_user_create_users and core_user_update_users are missing some core fields
Re: core_user_create_users and core_user_update_users are missing some core fields
Nicholas,
Are you also populating a Custom Field/s on creating a new user using core_user_create_users?
I am failing on filling it up.
Re: core_user_create_users and core_user_update_users are missing some core fields
Looking in the code there is support for custom fields in the web-service:
###
// Custom fields.
if (!empty($user['customfields'])) {
foreach ($user['customfields'] as $customfield) {
// Profile_save_data() saves profile file it's expecting a user with the correct id,
// and custom field to be named profile_field_"shortname".
$user["profile_field_".$customfield['type']] = $customfield['value'];
}
profile_save_data((object) $user);
}
###
Just check that you have the correct syntax there. Please find attached a screen-shot with a postman request.
Any other questions let us know.
Regards
Re: core_user_create_users and core_user_update_users are missing some core fields
I'm also having this issue. I have a customer with Moodle 3.2.x and I can't add phone1 or institution using core_user_create_users. I don't understand why I can update idnumber but not these field.
Re: core_user_create_users and core_user_update_users are missing some core fields
Please vote for my tracker:
https://tracker.moodle.org/browse/MDL-62657
And add the other missing fields in the comments!
Re: core_user_create_users and core_user_update_users are missing some core fields
Wonderful! I never got around to taking a stab at this myself, but this works retroactively at least back to Moodle 3.4.3 as well. It also happens to fix some weird errors I was getting even with the previously supported "city" and custom fields. Thanks Richard!
Re: core_user_create_users and core_user_update_users are missing some core fields
Hi Nicholas,
You are welcome... but can you help me? Which files do I have to replace in Moodle 3.5 to get this working?
I'm not profiting of these changes myself yet...
Re: core_user_create_users and core_user_update_users are missing some core fields
In 3.4.3, the only file I replaced was user/externallib.php
I guess I should note that I didn't test all the new fields, just `phone1` and I think `institution`. But like I said, before this change some fields like `city`, which were supposedly already supported, were not working at all for me. Putting in your modified user/externallib.php made `city` work too. It also eliminated some unspecified errors using space characters in custom field values.