Updating user field

Updating user field

by Alessio Niespolo -
Number of replies: 7

I'm using Moodle 3.8.4+. I'm new in moodle and don't know how to update the user fields by code. I would like to develop a script that automatically updates the "ICQ Number" optional field. I've updated the icq field in the mdl_user table but the field doesn't change in the user profile. How is it possible to reflect the changing in the user profile?

Attachment ICQ Number.png
Average of ratings: -
In reply to Alessio Niespolo

Re: Updating user field

by Randy Thornton -
Picture of Documentation writers
" I've updated the icq field in the mdl_user table but the field doesn't change in the user profile. "

Much user data like this is cached. If you updated the field okay in the database, then it will probably not update immediately for the user. You may need to purge caches on the server and/or log out and in as the user to refresh the cache and/or purge the local cache on your browser in order to see the edited fields.
In reply to Randy Thornton

Ri: Re: Updating user field

by Alessio Niespolo -
I've purged all the cache by the Site Administrator section, deleted the cache in my browser and log in as the user, but the "ICQ number" field is still blank
In reply to Alessio Niespolo

Re: Ri: Re: Updating user field

by Randy Thornton -
Picture of Documentation writers
Then I would definitely verify that it was actually changed. A download from Bulk user actions with all the user profile info should show those changes for those users (or not).
In reply to Randy Thornton

Ri: Re: Ri: Re: Updating user field

by Alessio Niespolo -
I've downloaded the user data from bulk user actions and the icq field is blank
In reply to Alessio Niespolo

Re: Ri: Re: Ri: Re: Updating user field

by Randy Thornton -
Picture of Documentation writers

Then the data is not in the database, otherwise it would be in the download file. You should check to make sure the method you used to add the data was working and it was in the right place.
In reply to Randy Thornton

Ri: Re: Ri: Re: Ri: Re: Updating user field

by Alessio Niespolo -
I've fixed, the problem is that the database was been duplicated on another server. I've updated the right database and see the ICR number in the interface.
In reply to Alessio Niespolo

Re: Ri: Re: Ri: Re: Ri: Re: Updating user field

by Randy Thornton -
Picture of Documentation writers
Alessio,

So, it was working, just not in the place you wanted smile Glad it is fixed.