Web services

core_user_create_users custom fields not being set

 
Family
core_user_create_users custom fields not being set
 

I am able to create a user using this string.

http://xxx.com/webservice/rest/server.php?wstoken=xxx&wsfunction=core_user_create_users&moodlewsrestformat=json&users[0][username]=chuck.yocum@spatialbiz.com&users[0][password]=StrokeM!26&users[0][firstname]=Chuck&users[0][lastname]=Yocum&users[0][email]=chuck.yocum@xxx.com&users[0][customfields][0][type]=ZENDESK_ID&users[0][customfields][0][value]=181818181459&users[0][customfields][1][type]=ORG_SHORT_NAME&users[0][customfields][1][value]=SBS


My custom fields are not being set!!  Anyone see anything wrong with those last two parameters.

 
Average of ratings: -
Picture of Dorel Manolescu
Re: core_user_create_users custom fields not being set
Plugin developers

Hi

Which moodle version are you using. It works for me with latest 3.5 moodle

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



 
Average of ratings: -