Preview and Current site different

Hi,

I am creating a homepage, which has a wix built login/signup button. I want to hide the profilw button when the user is not logged in, and show when they are. With my preview i can hide the button but when I test it with current site, it is not working.

Below is just a test of hiding the buttons
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady(() =>{
$w(‘#realProfileButton’).hide();
$w(‘#myprofile’).hide();
});

This is working fine with the preview but not the current site.
Thank you for your help

https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Thank you very much. I have been able to solve it.

sorry, I have another issue now:
My Id column in the database is locked in key, but I am trying to use the user’s login to access their profile. Do you know if I will need to unlock it before I can access their profiles? I have tried using the normal query:
wixData.query(“Members”).eq(“_id”, userId).find()

But this is returning the result of length zero, since I can’t access the id in the database.

Thank you