Creating a custom Log Out button

Hey guys!

If you’re trying to create a custom log out button for your wix-members website simply add this code to the page you need (or in your header/footer and it’ll work a treat!

Happy Coding!

import wixLocation from 'wix-location';
import wixUsers from 'wix-users';

$w.onReady(() => {

function logoutAndRedirect(event) {
    Promise.all([''), wixUsers.logout()]);

And here’s how each line of code works:

// Import the ‘wix-location’ module to be able to navigate to a different URL
import wixLocation from ‘wix-location’;

// Import the ‘wix-users’ module to be able to log out the current user
import wixUsers from ‘wix-users’;

// Set an event listener to run the ‘logoutAndRedirect’ function when the button with ID ‘button208’ is clicked
$w.onReady(() => {

// Define the ‘logoutAndRedirect’ function, which logs out the current user and redirects to the desired URL
function logoutAndRedirect(event) {

// Use Promise.all() to wait for both navigation and logout to complete
Promise.all([‘YourWebsiteURLHere’), wixUsers.logout()]);

Hello, this does not seem to take the user to a specific page on my site, i copied and pasted the code and modified the desired URL it only takes them back to the lightbox to sign in. do you have any tips or what I can be doing wrong?

Thank you