Search.../

promptLogin( )

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

Description

The promptLogin() function returns a Promise that resolves to the newly logged in user when the login has completed.

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

Notes:

  • The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

  • The APIs in wix-users 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.

Syntax

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

promptLogin Parameters

NAME
TYPE
DESCRIPTION
options
Optional

LoginOptions

The options that determine how the login dialog box appears.

Returns

Fulfilled - Information about the newly logged in user. Rejected - Message that the dialog was canceled, or any other reason the user failed to log in.

Return Type:

Promise<User>

Related Content:

Was this helpful?

Prompt the current user to login

Code Example

Copy Code
1import wixUsers from 'wix-users';
2
3// ...
4
5wixUsers.promptLogin()
6 .then( (user) => {
7 let userId = user.id; // "r5me-6fem-45jf-djhe-484349"
8 let isLoggedIn = user.loggedIn; // true
9 let userRole = user.role; // "member"
10 return user.getEmail();
11 } )
12 .then( (email) => {
13 let userEmail = email; // "user@something.com"
14 } )
15 .catch( (err) => {
16 let errorMsg = err; // "The user closed the login dialog"
17 } );
Prompt the current user to login with given options

Code Example

Copy Code
1import wixUsers from 'wix-users';
2
3// ...
4
5// The `modal` option is not yet available to all users.
6let options = {"mode": "login", "lang": "es", "modal": true};
7
8wixUsers.promptLogin(options)
9 .then( (user) => {
10 let userId = user.id; // "r5me-6fem-45jf-djhe-484349"
11 let isLoggedIn = user.loggedIn; // true
12 let userRole = user.role; // "member"
13 return user.getEmail();
14 } )
15 .then( (email) => {
16 let userEmail = email; // "user@something.com"
17 } )
18 .catch( (err) => {
19 let errorMsg = err; // "The user closed the login dialog"
20 } );