Search.../

updateUserFields( )

Updates an existing user by ID.

Description

The updateUserFields() function returns a Promise that resolves when the user with the specified ID has been updated.

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

Syntax

function updateUserFields(userId: string, userInfo: UserInfo): Promise<void>

updateUserFields Parameters

NAME
TYPE
DESCRIPTION
userId
string

ID of the user to update.

userInfo
UserInfo

The information to update.

Returns

Fulfilled - When the user is updated. Rejected - Error message.

Return Type:

Promise<void>

Was this helpful?

Update a user

Copy Code
1import wixUsersBackend from 'wix-users-backend';
2
3export function updateUserFields(userId, firstName, lastName, email, phone) {
4 wixUsersBackend.updateUserFields(userId, {
5 "firstName": firstName,
6 "lastName": lastName,
7 "emails": [email],
8 "phones": [phone]
9 } )
10 .then( () => {
11 // contact has been updated
12 } )
13 .catch( (err) => {
14 // there was an error updating the contact
15 } );
16}