thomas
January 29, 2018, 3:55am
1
Hi
I’m trying to change the on screen layout on login. However, I keep getting error messages.
There was an error in your script
TypeError: n is not a function
Could someone give me a nudge in right direction?
import wixUsers from 'wix-users';
wixUsers.onLogin( (user) => {
$w('#box18').show();
$w('#box22').hide();
$w('#box17').hide();
$w('#box24').show();
$w('#box21').show();
});
Many thanks
Thomas
Hi Thomas,
You should wrap the event with onReady function
import wixUsers from 'wix-users';
$w.onReady(() => {
wixUsers.onLogin( (user) => {
$w('#box18').show();
$w('#box22').hide();
$w('#box17').hide();
$w('#box24').show();
$w('#box21').show();
});
});
Roi
I’m trying to use custom interactions on my Website on login . but, I keep getting error messages.
45. Parameter 'user' is never used.
Could someone give me a nudge in right direction?
Thank you
Arman
That is a warning that doesn’t effect the functionality. You can delete this argument if you don’t use it.
Roi.
Thank you very much for your guide
Hi, I finally figured out how to solve this issue, or at least it has been working for me; you need two arguments. This works in the masterPage.js and on the “current page.” make sure you add both for the code to be read when you log in and log out, I placed this at the top of the page, so it’s read first.
This might be overkill, but I couldn’t find a better workaround. If anyone can simplify this code, please share.
Happy Coding.
//LogIn//
wixUsers . onLogin ( ( user ) => {
let isLoggedIn = user . loggedIn ; // true
if ( wixUsers . currentUser . loggedIn ) {
$w ( “#ItemName ” ). expand ();
} else {
$w ( “#ItemName ” ). collapse ();
}
});
$w . onReady (() => {
if ( wixUsers . currentUser . loggedIn ) {
$w ( “#ItemName ” ). expand ();
} else {
$w ( “#ItemName ” ). collapse ();
}
});