Check if logged in


I am simply trying to idenify if a user is logged in or not:

import wixUsers from ‘wix-users’ ;

$w.onReady( () => {
if (wixUsers.currentUser.loggedIn) { // if the user is logged in
$w( “#text38” ).text = "User: " +;
else { // the user isn’t logged in
$w( “#text38” ).text = “Not logged in”
} );

this doesn’t seem to be working. Using the Wix permissions rule in the editor does work. Can this be done via code?


Your code looks OK and should work. Check the console for errors.

Your code is working so far, you just missed a semi-colon at the $w(‘#text38’).text= “Not logged in” part…

import wixUsers from 'wix-users';

$w.onReady(function () {
 if(wixUsers.currentUser.loggedIn) {// if the user is logged in
    $w("#text38").text = "Logged In!";
  } else {// the user isn't logged in
    $w("#text38").text = "Not logged in";
1 Like