register( )


Registers a new site member.

The register() function returns a Promise that resolves to a RegistrationResult object when the member is either registered or pending registration.

The specified password must be between 4 and 100 ASCII characters.

See New Members to learn about verifying emails and approving members.

Notes:

  • The member data in the resolved Promise includes custom fields from your site's contacts only if they are added to your site members in your dashboard.

  • When your site's member signup settings are set to automatic approval, calling register() from wix-members-frontend (in page code) is as secure as calling register() from wix-members-backend (in backend code), unless you are implementing custom site registration using Velo forms. However, when registration is set to manual approval, calling register() from wix-members-backend allows you to build more secure approval flows by keeping tokens hidden from the frontend.

  • Registering a member in the backend always creates a new contact, even if a contact with the specified email already exists. To avoid this behavior, use register() from wix-members-frontend.

Method Declaration
Copy
function register(
  email: string,
  password: string,
  options: RegistrationOptions,
): Promise<RegistrationResult>;
Method Parameters
emailstringRequired

Email address the new member will use to log in.


passwordstringRequired

Password to assign to the new site member. Must be 4 to 100 ASCII characters.


optionsRegistrationOptions

Registration options.

Returns
Return Type:Promise<RegistrationResult>

This example contains custom fields: "Hobby" and "Favorite Meal".

JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { authentication } from "wix-members-backend"; /* Sample options value: * { * contactInfo: { * firstName: 'Javier', * lastName: 'Doe', * hobby: 'Basketball, * "favorite-meal": 'Pasta' * }, * privacyStatus: 'PUBLIC' * } */ export const myRegisterMemberFunction = webMethod( Permissions.Anyone, (email, password, options) => { return authentication .register(email, password, options) .then((registrationResult) => { return registrationResult; }) .catch((error) => { console.error(error); }); }, ); /* Promise resolves to: * { * "member": { * "_id": "efaaf13f-934e-4449-b0c2-304030767671", * "createdDate": "2021-08-01T12:28:42Z", * "updatedDate": "2021-08-01T12:28:41.847Z", * "status": "UNKNOWN", * "contactId": "efaaf13f-934e-4449-b0c2-304030767671", * "profile": { * "nickname": "Javier Doe", * "slug": "javierdoe" * }, * "privacyStatus": "UNKNOWN", * "activityStatus": "UNKNOWN" * }, * "status": "PENDING", * "approvalToken": "JWS.eyJraWQiOiJSc012MmV3MiIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaWRcIjpcImVmYWFmMTNmLTkzNGUtNDQ0OS1iMGMyLTMwNDAzMDc2NzY3MVwiLFwiY29sbGVjdGlvbklkXCI6XCI5YmVjNThlNi02NDExLTQ5OTEtOGU1ZC0wYWRhOTE4MmI5NWVcIn0iLCJpYXQiOjE2Mjc4MjA5MjEsImV4cCI6MTYyNzkyODkyMX0.zOuE8ZXRBQT4tPPFqvseE8xKm6kHrmHG3Lrndz7l7Ng" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?