Uncategorized

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

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...

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

Corvid , Wix Design, Project Planning, Private Tutoring

Services world wide

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.

Share this post

Loading...