Continue to check if a user is Logged in to perform an action

Updated: Sep 14, 2020


 

Good to Know #1

The Site Code


Make sure the add the code on the Site tab instead of the Page tab, otherwise the code will only be triggered when a person lands on the single page where you added the page code.



Code for the single item dynamic page



import wixUsers from 'wix-users';

$w.onReady(function () {
    checkIfLoggedIn();
});

function checkIfLoggedIn() {
    setTimeout(() => {
 if (wixUsers.currentUser.loggedIn) {
 //do something if they are logged in
        } else {
 // do something else and run the code again to continue checking
            checkIfLoggedIn();
        }
    }, 16000);  //time in milliseconds
}
        

 

Author

by Code Queen


Stuck on a project? Hire Code Queen, LLC!

Schedule a phone call or video call directly online. In a different time zone? No problem! Code Queen currently has clients around the world.


Online Booking: Discovery Session

Contact Form: Send project details

211 views0 comments

disclaimer