Web services Optional user field

Web services Optional user field

by Fernando Sánchez Zamora -
Number of replies: 6

Hello,

how can I set an optional user field using webservices 'core_user_create_users' external function?

Thanks in advance,
Fernando

Average of ratings: -
In reply to Fernando Sánchez Zamora

Re: Web services Optional user field

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
There is a 'customfields' array as part of that call for setting these fields. Is that what you mean?


customfields  Optional //User custom fields (also known as user profil fields)
    list of ( 
        object {
            type string   //The name of the custom field
            value string   //The value of the custom field
In reply to Howard Miller

Re: Web services Optional user field

by Fernando Sánchez Zamora -
Hello Howard,

I know that feature, but my goal is to set the predefined fields called 'Optional fields' in the user profile, like 'Web page', 'ID Skype', 'ID AIM', etc. The field i would like to set is 'Address'.

Thanks!
Attachment moodle_optional_fields.JPG
In reply to Fernando Sánchez Zamora

Re: Web services Optional user field

by John Doyle -

Hi, 

Did you ever get this working as I am also trying to set the optional fields such as 'aim', 'address', 'institution', etc. using the 

core_user_update_users and core_user_create_users external API functions but I keep getting "Invalid parameter value detected" when I add in "customfields":{"0":{"value":"UG","type":"aim"}} into the post data of the api functions, i have also tried different combinations 
"customfields":{"0":{"aim":"UG","type":"string"}}, but no joy
Regards

John
In reply to John Doyle

Re: Web services Optional user field

by Fernando Sánchez Zamora -
Hi,

no I didn´t get that working. I had to create new 'Other fields' to populate them with the desire information.

Good luck!
Fer
In reply to Fernando Sánchez Zamora

Re: Web services Optional user field

by John Doyle -
Hi

Thanks for replying, so it looks like it is a fault with the API code...

Thanks again
In reply to Fernando Sánchez Zamora

Re: Web services Optional user field

by John Doyle -
Hi Fernando,

I think the solution we are both looking for is discussed here https://tracker.moodle.org/browse/MDL-53135 and basically all we have to do is add the default mdl_user fields that are missing to /path/to/moodle/install/user/externallib.php i have tested with one attribute and it does work...
why this hasn't been added to core is beyond me

regards

john