Hi there, any ideas for coding the start of this. I have two strips one which i would like to show the logged-in owner who is viewing a dynamic page and the second strip should only be shown to a non-logged in user who is viewing the dynamic page without being a member.
I’m thinking something along the lines of
get current user - is logged in owner
show strip 1
hide strip 2
else - not logged in or a member
show strip 2
hide strip 1
great thanks, i have imported Wix users at the top of the code page, just want to check this error in red please as showing parsing error unexpected token
let user = wixUsers.currentUser; let isLoggedIn = user.loggedIn;
if (isLoggedIn){
doIfLoggedIn();
} else {
$w(“#columnStrip12”).expand();
$w(“#columnStrip13”).collapse();
}
})
wixUsers.onLogin( (user) => { let userId = user.id; let isLoggedIn = user.loggedIn;
doIfLoggedIn();
} ); function doIfLoggedIn(){
$w(“#columnStrip12”).expand();
$w(“#columnStrip13”).collapse();
}
sorry yes, its because i thought i already had one as follows from a previous addition of code import wixUsers from ‘wix-users’;
$w.onReady(() => {
$w(“#dynamicDataset”).onReady(() => {
Somehow managed to lose the functionality here. I have reviewed your the posts and replaced like for like as follows but not sure why this isn’t working now.
There are a couple of issues that might be connected, like the fact that I cannot get a string to pick up the field key either
I thought it might have been to do with user permissions?
$w.onReady(() => { let user = wixUsers.currentUser; let isLoggedIn = user.loggedIn;
$w.onReady(() => { if (isLoggedIn){
doIfLoggedIn();
} else {
$w(“#columnStrip13”).expand();
$w(“#columnStrip12”).collapse();
}
})
wixUsers.onLogin( (user) => { let userId = user.id; let isLoggedIn = user.loggedIn;
doIfLoggedIn();
} ); function doIfLoggedIn(){
$w(“#columnStrip12”).expand();
$w(“#columnStrip13”).collapse();
}
You did the opposite. Don’t remove the “let” from the beginning. Move it from the onLogin.
You know that once you declare a variable in the global scope, you can’t declare it again.
J.D. this was working so not sure if this has anything to do with the dynamic page being re-titled ? I don’t remember changing any of this code although i must have done something to it