Hello Wix.com,
I would like the visitor to be re-directed to different websites, so I assigned each button in the picture with different location:
Here are the codes I wrote:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady(()=>{
if (wixUsers.currentUser.loggedIn){
$w(‘#loginButton’).label=“Logout”;
$w(‘#button39’).hide();
$w(‘#button10’).hide();
$w(‘#box11’).hide();
$w(‘#ProfileButton’).show();
$w(‘#profileButton’).show();
$w(‘#CoffeeButton’).show()}
else {
$w(‘#loginButton’).label=“Login/Register”;
$w(‘#button39’).show();
$w(‘#button10’).show();
$w(‘#box11’).show();
$w(‘#ProfileButton’).show();
$w(‘#profileButton’).hide();
$w(‘#CoffeeButton’).hide()}
});
export function ProfileButton_click(){
if (wixUsers.currentUser.loggedIn){
wixUsers.logout()
.then(()=>{
$w(‘#loginButton’).label=“Login/Register”;
$w(‘#button39’).show();
$w(‘#button10’).show();
$w(‘#box11’).show();
$w(‘#ProfileButton’).show();
$w(‘#profileButton’).hide();
$w(‘#CoffeeButton’).hide();
wixLocation.to(‘/successfullogout’); //NOT WORKING
})
. catch ((err)=>{
console.log(err)})
}
else {
wixLocation.to(/login
); //WORKING
}
}
export function loginButton_click(){
if (wixUsers.currentUser.loggedIn){
wixUsers.logout()
.then(()=>{
$w(‘#loginButton’).label=“Login/Register”;
$w(‘#button39’).show();
$w(‘#button10’).show();
$w(‘#box11’).show();
$w(‘#ProfileButton’).show();
$w(‘#profileButton’).hide();
$w(‘#CoffeeButton’).hide();
wixLocation.to(‘/successfullogout’); //NOT WORKING
})
. catch ((err)=>{
console.log(err)})
}
else {
wixLocation.to(/login
); //WORKING
}
}
export function CoffeeButton_click(event) {
wixLocation.to(‘/Members/${wixUsers.currentUser.id}/’); //NOT WORKING
}
export function profileButton_click(event) {
wixLocation.to(‘/Members/${wixUsers.currentUser.id}/’); //NOT WORKING
}
Sadly, none wixLocation.to works. Can anyone help, please? Here is my site: https://www.elroblehomecare.com/login
Thanks,
Louise