Hi
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: " + wixUsers.currentUser.id; } 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?
Thanks
Hello, 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"; } });
Hi,
Your code looks OK and should work. Check the console for errors.