updateUserInfo() is not updating

Hi,
I built a customized registration with additional fields. Registration works great, but when user updates the profile in the customized member area, the updateUserInfo() ends with success, but the contact is not updated.
Any idea?

$w('#submit').onClick(() => {
    $w("#err").hide();
    $w("#success").hide();
    
    wixUsers.currentUser.getEmail()
        .then((email) => {
            let userInfo = {
                "firstName": $w('#first').value,
                 "lastName": $w('#last').value,
                 "picture": $w('#image').src,
                 "nickname": $w('#nick').value,
                 "phones": [$w('#phone').value],
                 "fbLink": $w('#facebook').value,
                 "dateOfBirth": $w('#birth').value,
                 "gender": $w('#gender').value,
                 "orientation": $w('#orientation').value
                 };

               updateUser(userId, userInfo)
                   .then(() => {
                        $w("#success").show();
                        console.log("user saved")
                    })
                    .catch((err) => {
                        console.log(err);
                        $w("#err").show();
                    });
            });
    });

And this is the backend code:

export function updateUser(userId, contact) {
        return wixUsers.updateUserFields(userId, contact)
                .catch((err) => {
                        function log() {
                            wixData.insert("log", { "title": err });
                            }
                });
}

Thanks a lot:)
Dafna

See here: https://www.wix.com/corvid/reference/wix-users-backend.html#updateUserFields
how to update user info (have a look at the example there).

In the line updateUser(userId, userInfo) , I see where you’re building the userInfo object, but I don’t see where userId is coming from. Did you check if userId is correct?

If it is just a customised member area, then you could just use Wix existing member profile tutorial.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Works fine with the custom signup form collecting whatever user inputs you want and then when the user is manually approved as a site member, the user inputs get saved into the Members dataset from the Wix tutorial above and they will be displayed on the members profile page when they first view it.

Then they can simply edit, change or add anything to the user inputs that you add to that page yourself.

Yes. I print it to log.
It’s

This article works with new Users collection. I want to work with the native members collection. I assume that if the user can submit contrnt to additional fields in the crm, he will have the option to edit same data.
Thanks:)

The api has 2 different names for same function: updateUserInfo () and updateUserFields.
The updateUse6() returts with error regarding the function’s name.
The updateUse6() returns with error regarding the function’s name.the function’s name.

So as J. D. says, use the code example to suit your own needs.

Examples

Update a user

import wixUsers from 'wix-users-backend';

export function updateUserInfo(userId, firstName, lastName, email, phone) {
  wixCrm.updateUserInfo(userId, {
      "firstName": firstName,
      "lastName": lastName,
      "emails": [email],
      "phones": [phone]
  } )
    .then( () => {
      // contact has been updated
    } )
    .catch( (err) => {
      // there was an error updating the contact
    } );
}

Only the properties passed in the ContactInfo object will be updated. All other properties will remain the same.

As you know you can only update the userInfo fields plus any custom fields.
Page Not Found - Velo API Reference - Wix.com

Now note that these custom fields that are in your Wix CRM Contacts List need to be added to your code as they are exactly in your Contacts List and not as the normal way that we code the rest of the fields needed.

Also remember that Wix Users is for Site Members whilst Wix CRM is for all your Contacts and not all of them will be members.

If you want to use Wix CRM, then you will need to use Wix CRM backend and the updateContact function.
wix-crm-backend - Velo API Reference - Wix.com

Examples

Update an existing contact

This example contains a backend function that updates a contact.

import wixCrm from 'wix-crm-backend';

export function myBackendFunction(contactId, firstName, lastName, email, phone) {
  wixCrm.updateContact(contactId, {
      "firstName": firstName,
      "lastName": lastName,
      "emails": [email],
      "phones": [phone]
  } )
    .then( () => {
      // contact has been updated
    } )
    .catch( (err) => {
      // there was an error updating the contact
    } );
}

I have done for a Choir website with the use of Wix CRM and using custom fields.

import wixCRM from 'wix-crm';

$w.onReady(function () {
$w("#JoinUsForm").onAfterSave(() => {
let startDate = $w("#startDate").value;
let firstName = $w('#firstName').value;
let lastName = $w('#lastName').value;
let email = $w("#email").value;
let choirRole = $w("#choirRole").value;
let readMusic = $w("#readMusic").value;
let choirBefore = $w("#choirBefore").value;
let startNow = $w("#startNow").value;

wixCRM.createContact({ 
"firstName": firstName,
"lastName": lastName,
"emails": [email],
"Choir Role": choirRole,
"Read Music": readMusic,
"Choir Before": choirBefore,
"Start Now": startNow,
"Start Date": startDate
}) 
.then((contactId) => { 
// Need to use the triggered email name
return wixCRM.emailContact('joiningusform', contactId, { 
"variables": { 
// Need to use the triggered email variable names
"firstName": firstName,
//"lastName": $w('#lastName').value, << - not defined in the triggered email
//"emails": [$w("#email").value], << - cannot have array here
"email": email, // << - correct variable is email not emails
"choirRole": choirRole,
"readMusic": readMusic,
"choirBefore": choirBefore,
"startNow": startNow,
"startDate": startDate.toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'})
} 
}); 
}) 
.catch((err) => { 
// handle the error if the email wasn't sent
console.log(`Error: ${err}`);
}); 
}); 
}); 

Correct me if I’m wrong, but the marked line in the API document should be:

wixUsers.updateUserFields