I am using member area to logout, on Logout I update database table therefore I need to detect when logout function performs so that I can be able to update database table.
I see onLogin event but I don't see onLogout, some people has suggested that I should use .then promise but I don't call logout from code.
Can someone please let me know how to call logout when click on member area logout button.
or Let me know how to detect logout function.
Hello,
You can use the wixusers.logout function to log users out. If you wanted to just check when the user has logged out you can run a condition that checks if a user is not logged in.
I created a simple example for demonstration:
import wixUsers from 'wix-users'; $w.onReady(function () { let user = wixUsers.currentUser; let isLoggedIn = user.loggedIn; if(!isLoggedIn){ console.log("Not logged in"); } })
See currentuser API
I hope this helps!
Best regards,
Miguel