Introduction
The backend Wix Members API allows you to manage member access to your site as well as view and manage site members.
To use the backend Wix Members API,
import the applicable named exports from wix-members-backend
:
js | Copy Codeimport { authentication, authorization, badges, currentMember, members } from 'wix-members-backend';
Note: Functions in the Authentication, Authorization, Badges, and Members APIs can only be triggered by site collaborators with Manage Site Members permissions.
Custom fields
Member profiles can contain custom data,
located in the member object at contactDetails.customFields
.
The member object is returned when calling these functions:
The Members API works with custom fields that are added to the member profile in the Dashboard. Custom fields that haven't been added to the member profile aren't available through the Members API. When retrieving members, empty fields are not returned. You can query, create, rename, and delete custom field definitions with the Contacts Extended Fields API.
Data structure
The member's customFields
object contains key:object pairs.
The key is defined in the Contacts Extended Fields API.
The paired object is structured as follows:
js | Copy Code{// ...customFields: {<key_1>: {name: 'Field 1 Display Name',value: 'string' // Value stored for the member},<key_2>: {name: 'Field 2 Display Name',value: 12345 // Value stored for the member}}}
The paired object contains these properties:
name
: Display name. Read only.value
: Value stored for the member.
Retrieve custom field keys
For a list of your site's custom field keys, use this function in your backend code:
js | Copy Codeimport { contacts } from 'wix-crm-backend';export async function listCustomFieldKeys() {const queryResults = await contacts.queryExtendedFields().find();// Filters for custom fields (where fieldType is USER_DEFINED), then converts to an array of keysreturn queryResults.items.filter(field => field.fieldType === 'USER_DEFINED').map(field => field.key);}
Was this helpful?