loggedIn( )


Indicates whether the site visitor is a logged-in member.

The loggedIn() function returns a boolean value indicating whether the current visitor is logged in as a site member.

If a member is logged in, loggedIn() returns true. Otherwise, loggedIn() returns false.

Method Declaration
Copy
function loggedIn(): Promise<boolean>;
Request
This method does not take any parameters
Returns
Return Type:Promise<boolean>
JavaScript
import { authentication } from "@wix/site-members"; // ... const isLoggedIn = await authentication.loggedIn(); if (isLoggedIn) { console.log("Member is logged in"); } else { console.log("Member is not logged in"); }
Errors

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

Did this help?

login( )


Logs a registered member in with an email and password.

The login() function returns a Promise that resolves when the member with the specified email address and password is logged in.

The login() function only works with existing members. To register a new member use the register() function.

Note:

  • 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.
Method Declaration
Copy
Method Parameters
emailstringRequired

Login email address.


passwordstringRequired

Member password.

JavaScript
Errors

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

Did this help?

logout( )


Logs the current member out of the site.

The logout() function logs the current member out of the site.

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.

Method Declaration
Copy
Request
This method does not take any parameters
JavaScript
Errors

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

Did this help?

onLogin( )


Sets the function that runs when a member logs in.

The onLogin() event handler runs when a member logs into your site.

onLogin receives a currentMember object for the logged-in member, which contains the CurrentMember methods you can use to retrieve the member's information.

Usually, you want to call onLogin() in the masterPage.js file in the code editor so that the onLogin() event handler runs no matter which page a member uses to log in.

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.

Method Declaration
Copy
Method Parameters
handlerfunctionRequired

handler(currentMember: CurrentMember): void Function name or expression to run when a member logs in.

Run code when a member logs in
JavaScript
Errors

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

Did this help?