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

153 views0 comments

disclaimer

a quick note about our website content

Our free and premium content is non-exclusive, meaning you are not the only one with access to the content. You can customize our content to fit your end product. Redistribution of our content is strictly prohibited. This means you cannot make our content available to others as-is, stand-alone products or stock products in ANY LANGUAGE, regardless if you offer our content for free or not.

  • Code Queen Facebook Group Icon
  • Facebook Logo
  • Twitter Logo
  • YouTube logo
  • Instagram Logo
  • Linkedin Logo

© 2021.  All Rights Reserved by Code Queen, LLC.