Search.../

promptLogin( )

Prompts the current visitor to log in as a site member.

Description

The promptLogin() function returns a Promise that resolves when the login has completed.

If the visitor cancels the form without logging in, the Promise is rejected.

The promptLogin() function cannot be called before the page is ready.

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 APIs in wix-members-frontend can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.

  • If you return or await the promptLogin() function when calling from onReady(), the page will be prevented from loading. To handle the resolved promise, use .then() and .catch().

Syntax

function promptLogin([options: LoginOptions]): Promise<void>

promptLogin Parameters

NAME
TYPE
DESCRIPTION
options
Optional
LoginOptions

The options that determine how the login dialog box appears.

Returns

Fulfilled - When the member is logged in. Rejected - Message that the dialog was canceled, or any other reason the member failed to log in.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Prompt the current visitor to log in

Copy Code
1import { authentication } from 'wix-members-frontend';
2
3// ...
4
5// Sample options value:
6// {
7// mode: 'login',
8// modal: true
9// }
10
11authentication.promptLogin(options)
12 .then(() => {
13 console.log('Member is logged in');
14 })
15 .catch((error) => {
16 console.error(error);
17 });