register( )
Registers a new site member.
Description
The register()
function returns a Promise that resolves to a RegistrationResult
object when the member is 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 APIs in
wix-members-frontend
are only partially functional when previewing your site. View a published version of your site to see their complete functionality.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 a new member signs up using an email address that's already in your site's Contact List, a notification is displayed and a confirmation email is sent to the new member. To register a member without displaying the notification, use
register()
from wix-members-backend (this does not suppress the confirmation email).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 callingregister()
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, callingregister()
from wix-members-backend allows you to build more secure approval flows by keeping tokens hidden from the frontend.
Syntax
function register(email: string, password: string, [options: RegistrationOptions]): Promise<RegistrationResult>
register Parameters
NAME
TYPE
DESCRIPTION
Email address the new member will use to log in.
Password to assign to the new member. Must be 4 to 100 ASCII characters.
Registration options.
Returns
Fulfilled - When the member is registered. Rejected - Error message.
Return Type:
NAME
TYPE
DESCRIPTION
Registration status.
One of:
"PENDING"
: The member must be approved before they can log in to the site."ACTIVE"
: The member is approved and can log in to the site.
Token for approving the member
with the approveByToken()
function. approvalToken
is safe to pass via email or from page code to
backend code.
Returned when status
is "PENDING"
.
The registered member.
Returned when status
is "ACTIVE"
.
Was this helpful?
Register a site member
This example contains a custom field, "Hobby".
1import { authentication } from 'wix-members-frontend';23// ...45/* Sample options value:6 * {7 * contactInfo: {8 * firstName: 'Juan',9 * lastName: 'Doe',10 * picture: 'https://static.parastorage.com/unpkg-semver/communities-blog-statics/assets/wix-logo.png',11 * hobby: 'Football'12 * },13 * privacyStatus: "PRIVATE"14 * }15 */1617authentication.register(email, password, options)18 .then((registrationResult) => {19 const status = registrationResult.status;2021 if (status === "PENDING") {22 // When the site is configured for manual approval,23 // status is "PENDING" and approvalToken is returned.24 const approvalToken = registrationResult.approvalToken;25 console.log('Member registered and waiting for approval:', registrationResult);26 } else {27 // When the site is configured for automatic approval,28 // status is "ACTIVE" and the member is approved and logged in.29 // To prevent logging in the member automatically,30 // use the backend function: wix-members-backend.authentication.register()31 console.log('Member registered and logged in:', registrationResult);32 }33 })34 .catch((error) => {35 console.error(error);36 });