Redirect after LoggedIn / Signup (By customer form)

Good evening,

I am struggling with an issue: how to redirect the users after they are LoggedIn to a specific page? I am using a standard script from Wix Academy as below, which works perfectly. Currently after the user loggedIn, it redirect me to the Member Login Page (which I would like to change).

I think I should include wixLocation.to(“/”); somewhere, but I don’t know how to fix this issue. Can anyone give any advice?

If you need more info, please let me know.

Thank you!

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady( () => {
if (wixUsers.currentUser.loggedIn) {
$w(“#button8”).label = “Logout”;
$w(“#button9”).show();
}
else {
$w(“#button8”).label = “Login”;
$w(“#button9”).hide();
}
} );

export function button8_click() {
// user is logged in
if (wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button8”).label = “Login”;
$w(“#button9”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;

// prompt the user to log in
wixUsers.promptLogin( {“mode”: “login”} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query(“Membershipdatabase”)
.eq(“_id”, userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
“_id”: userId,
“email”: userEmail
};
// add the item to the collection
wixData.insert(“Membershipdatabase”, toInsert)
. catch ( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w(“#button8”).label = “Logout”;
$w(“#button9”).show();
} )
. catch ( (err) => {
console.log(err);
} );
}
}

export function button9_click() {
wixLocation.to(/Membershipdatabase/Update/${wixUsers.currentUser.id});
}

Just change the url in wix location.

Or add another button that links to another page that only shows up like the members profile button from this tutorial when the member is logged in.