Custom fields for User profile does not update to mdl_user

Custom fields for User profile does not update to mdl_user

by T K -
Number of replies: 6

Moodle version 3.4

We have created 5 new custom fields, we did the following to be able to add/update users via webservice:

1)  added them at the 'Other fields' section in the Moodle User Profile fields

2) Added the fields in the mdl_user table

3) Updated necessary functions at 

user/externallib.php

However currently we noticed that when creating/updating other fields, it is not updating to the mdl_user fields.

other fields directly updated

Likewise when we create users via webservice, the data is correctly reflected on the mdl_user but does not appear on the 'Other fields' of the user profile.

mdl_user

fields dont appear

What DB is the Other fields using? How can I change this?

Which DB table does this API parameter refer to?
users[0][customfields][0][type]


Average of ratings: -
In reply to T K

Re: Custom fields for User profile does not update to mdl_user

by C Behan -
Hi Karishma,

This post might help you: https://moodle.org/mod/forum/discuss.php?d=384697#p1550727
In reply to C Behan

Re: Custom fields for User profile does not update to mdl_user

by T K -
Thanks for sharing.
I dont quite get it. None of the 2 tables contain the new fields I created at Profile fields. Also when I try to query my users by ID there is no rows returned.
In reply to T K

Re: Custom fields for User profile does not update to mdl_user

by T K -

Can someone help me here pls?

In reply to T K

Re: Custom fields for User profile does not update to mdl_user

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
When you create user profile fields, it adds a new record to the user_info_field for each field. When data is added to this field, it is added to the user_info_data table, referencing the user_info_field id for that field.

You don't need to add anything to the user table. It's not looking there for the data.

Have a look at your user_info_field and user_info_data tables, you'll see the data you entered in your form there.

If you're using the webservice to update and get info about users (e.g. core_user_get_users) then the profile fields will be returned under customfields.
Average of ratings: Useful (1)
In reply to Mark Sharp

Re: Custom fields for User profile does not update to mdl_user

by T K -
Hi Mark,
Thanks for your reply.

Yes I found my custom field data in the user_info_data and user_info_field.

In the webservice for core_user_create_users, we only have the below customfields, whereas in the profile custom fields i have 5 fields, how do I add more customfields for webservice use?

users[0][customfields][0][type]= string
users[0][customfields][0][value]= string
In reply to Mark Sharp

Re: Custom fields for User profile does not update to mdl_user

by T K -
So i thought over this, and I realise the customfield can be an array of datas?
I tried the below array of data (this comes after the rest of the user details, of course), and i got the below error.
custom array

customfields error