I’m failing in updating the language field of the current user in the backend using updateUserFields of wix-users-backend. Is there bug or am I doing something wrong?
This code is placed in the back-end (backend/crmModule.jsw)
import wixUsersBackend from 'wix-users-backend';
...
export async function updateContactDetails(contactId, contactInfo) {
let userResponse = await wixUsersBackend.updateUserFields(contactId, {
"firstName": contactInfo.firstName,
"lastName": contactInfo.lastName,
"language": contactInfo.language
})
let userDetails = await wixUsersBackend.getUser(contactId);
return userDetails;
}
This code is in the front end:
import { updateContactDetails } from 'backend/crmModule';
...
export async function dropdownLanguage_change(event) {
contact.firstName = $w("#inputFirstName").value;
contact.lastName = $w("#inputLastName").value;
contact.language = $w("#dropdownLanguage").value;
contact.country = $w("#dropdownCountry").value;
$w("#txtStatus").text = "" + JSON.stringify(contact);
let update = await updateContactDetails(contact.id, contact);
$w("#txtStatus").text = $w("#txtStatus").text + " >> after save >> " + JSON.stringify(update);
}
So the language of my user-account is “fr” but I want to change it to “nl”. After I changed it on the dropdown, it gives the following print on my page :
{
"id":"666c6cc0-cac2-4087-823f-7389f6f1023d",
"loginEmail":"tom.Xxxxx@somemail.com",
"slug":"tomXxxxx",
"language":"nl",
"firstName":"Tom",
"lastName":"Xxxxx",
"fullName":"Tom Xxxxx",
"picture":"https://someurl",
"email":"tom.Xxxxx@somemail.com",
"phone":"","country":"BEL"
}
>> after save >>
{
"id":"666c6cc0-cac2-4087-823f-7389f6f1023d",
"loginEmail":"tom.Xxxxx@somemail.com",
"memberName":"Tom Xxxxx",
"firstName":"Tom",
"lastName":"Xxxxx",
"nickname":"Tom Xxxxx",
"slug":"tomXxxxx",
"language":"fr",
"status":"ACTIVE",
"creationDate":"2019-02-16T19:54:59Z",
"lastUpdateDate":"2020-04-05T15:18:06.899Z",
"lastLoginDate":"2020-04-05T14:56:47Z",
"emails":["tom.Xxxxx@somemail.com"],
"phones":[],
"labels":["contacts-mobile","contacts-site_members_approved","contacts-new"],
"picture":{"url":"https://someurl"},
"groups":[],
"contactId":"666c6cc0-cac2-4087-823f-7389f6f1023d"
}
where you can see that the language didn’t update.
Worth mentioning, I did also attempts, changing the first and lastname too, and they did change, but not the language. So i’m pretty conviced my code is correct. Is this a bug of the UpdateUserFields?