I followed the guide everyone uses to create a custom member area and like others I find the inability to customize the login form a pain. So, wondering how I can redirect new signups to the update details page where they can then complete the rest of their information before its committed to the DB. Where in the code would I place the wixLocation.to line? I figured it may be under if (results.items.length === 0) however after testing it never redirects.
Hey there Christian! Were you able to get anywhere on this?
Tomer, I am attempting the same thing. My goal is to redirect after a new sign-up only to go to a terms and agreement page (or lightbox). Either this, or add an agreement checkbox on the initial signup page using the Wix Members App. Similar to how the user can opt in to the community forum upon sign-up.
Hoping to meet an approaching deadline soon, if anyone out there is able to shed some light!
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
export function button1_click(event, $w) {
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("Company")
.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("Company", toInsert)
.catch((err) => {
console.log(err);
});
}
// update buttons accordingly
$w("#login").collapse();
$w("#profileimage").expand();
})
.catch((err) => {
console.log(err);
});
wixLocation.to(`/confirm`);
}
I can’t redirect the user on their first log in either… So everytime they log in they would be redirected to that page…
Well the best thing would be to redirect to /confirm after the sign up or to /welcome after a log in, could I do that? In which part of the promise chain should I wrote the wixlocation to?