updateMember( )
Updates a member's properties.
Description
Only the requested fields are updated.
To clear a field's value, set an empty value with an empty string ""
.
Notes: Updating the
contact.addresses
,contact.emails
, orcontact.phones
array overwrites the entire array, so any existing values you want to retain must be passed in theupdateMember()
call along with the new values to add. However, passing an empty array will have no effect, and these functions must be used to clear all data from the respective array:
- To clear
contact.addresses
, usedeleteMemberAddresses()
.- To clear
contact.emails
, usedeleteMemberEmails()
.- To clear
contact.phones
, usedeleteMemberPhones()
.
Note: Only logged-in members can call this function without elevated permissions. To call this function as a different identity, elevated permissions are required.
Syntax
function updateMember(_id: string, member: UpdateMember): Promise<Member>
updateMember Parameters
NAME
TYPE
DESCRIPTION
Member ID.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
Date and time when the member was created.
Member ID.
Date and time when the member was updated.
Member activity status.
ACTIVE
: Member can write forum posts and blog comments.MUTED
: Member cannot write forum posts or blog comments.UNKNOWN
: Insufficient permissions to get the status.
Contact ID.
Date and time when the member last logged in to the site.
Email used by the member to log in to the site.
Whether the email used by the member has been verified.
Member privacy status.
PUBLIC
: Member is visible to everyone.PRIVATE
: Member is hidden from site visitors and other site members. Member is returned only to site contributors and apps with the appropriate permissions.UNKNOWN
: Insufficient permissions to get the status.
Profile display info.
Member site access status.
PENDING
: Member created and is waiting for approval by site owner.APPROVED
: Member can log in to the site.OFFLINE
: Member is a guest author for the site blog and cannot log in to the site.BLOCKED
: Member is blocked and cannot log in to the site.UNKNOWN
: Insufficient permissions to get the status.
Was this helpful?
1import { Permissions, webMethod } from 'wix-web-module';2import { members } from 'wix-members.v2';34/* Sample _id value: 'f32cbc51-a331-442b-86c2-2c664613e8b9'5 *6 * Sample member value:7 * {8 * contact: {9 * emails: ['claudes.new.email@example.com']10 * }11 * }12 *13 */1415export const myUpdateMemberFunction = webMethod(16 Permissions.Anyone, (id, member) => {17 return members.updateMember(id, member)18 .then((member) => {19 return member;20 })21 .catch((error) => {22 console.error(error);23 });24});2526/* Promise resolves to:27 * {28 * "_id": "f32cbc51-a331-442b-86c2-2c664613e8b9",29 * "_createdDate": "2021-08-02T23:14:42.000Z",30 * "_updatedDate": "2021-08-02T23:14:58.345Z",31 * "contactId": "f32cbc51-a331-442b-86c2-2c664613e8b9",32 * "activityStatus": "UNKNOWN",33 * "privacyStatus": "UNKNOWN",34 * "status": "UNKNOWN",35 * "contact": {36 * "firstName": "Claude",37 * "lastName": "Morales",38 * "phones": [39 * "0747-769-460"40 * ],41 * "emails": [42 * "claudes.new.email@example.com"43 * ],44 * "addresses": [45 * {46 * "_id": "e151960c-04a7-43ef-aa17-a134916ded07",47 * "addressLine": "9373 Park Avenue",48 * "addressLine2": "Berkshire",49 * "city": "Ely",50 * "subdivision": "GB-ENG",51 * "country": "GB",52 * "postalCode": "PD50 8EU"53 * },54 * {55 * "_id": "88a6f2ed-83d5-435d-ab55-4af1cb1b7861",56 * "country": "IE"57 * }58 * ],59 * "customFields": {60 * "someKey": {61 * "value": "someValue"62 * }63 * }64 * },65 * "profile": {66 * "nickname": "Claude Morales",67 * "slug": "claudemorales"68 * }69 * }70*/
1import { members } from 'wix-members.v2';23/* Sample _id value: 'f32cbc51-a331-442b-86c2-2c664613e8b9'4 *5 * Sample member value:6 * {7 * contact: {8 * emails: ['claudes.new.email@example.com']9 * }10 * }11 *12 */1314export async function myUpdateMemberFunction(_id, member){15 try {16 const updatedMember = members.updateMember(_id, member);17 console.log('Successfully updated member!', member);18 } catch (error) {19 console.error(error)20 // Handle the error21 }22};2324/* Promise resolves to:25 * {26 * "_id": "f32cbc51-a331-442b-86c2-2c664613e8b9",27 * "_createdDate": "2021-08-02T23:14:42.000Z",28 * "_updatedDate": "2021-08-02T23:14:58.345Z",29 * "contactId": "f32cbc51-a331-442b-86c2-2c664613e8b9",30 * "activityStatus": "UNKNOWN",31 * "privacyStatus": "UNKNOWN",32 * "status": "UNKNOWN",33 * "contact": {34 * "firstName": "Claude",35 * "lastName": "Morales",36 * "phones": [37 * "0747-769-460"38 * ],39 * "emails": [40 * "claudes.new.email@example.com"41 * ],42 * "addresses": [43 * {44 * "_id": "e151960c-04a7-43ef-aa17-a134916ded07",45 * "addressLine": "9373 Park Avenue",46 * "addressLine2": "Berkshire",47 * "city": "Ely",48 * "subdivision": "GB-ENG",49 * "country": "GB",50 * "postalCode": "PD50 8EU"51 * },52 * {53 * "_id": "88a6f2ed-83d5-435d-ab55-4af1cb1b7861",54 * "country": "IE"55 * }56 * ],57 * "customFields": {58 * "someKey": {59 * "value": "someValue"60 * }61 * }62 * },63 * "profile": {64 * "nickname": "Claude Morales",65 * "slug": "claudemorales"66 * }67 * }68*/