The question here is–> What exactly happens AFTER…
wixUsers.register(email, password, {
contactInfo: {
"firstName": $w('#input1').value,
"lastName": $w('#input2').value,
"loginEmail": $w('#input3').value,
}
})
Yes —> It follows the —> .then()-code-part…
Where you get some results and trying to redirect…
.then( (result) => {
let resultStatus = result.status; console.log(results)
wixWindow.lightbox.close();
wixLocation.to("/new-memeber-form");
});
But could it be, that even more happens?
Could it be, that the new registered user immediately and automaticaly will be logged-in after registration?
I have a similar code running on my site…
https://www.media-junkie.com/login-page
You can try to register–> Follow the REGISTER-INSTRUCTIONS & see what happens !
My code has similarity to yours (but a little bit more expanded & complex).
async function start_Registration(){console.log("Registration running...")
if(uploadAvatarUrl){console.log("Avatar-Setup completed...")
msg[0] = "";
msg[1] = "Registration in process...";
msg[2] = "Please be patient.";
msg[3] = "";
msg[4] = "";
hide_AvatarSetup(), show_infoMessage();
wixUsers.register($w('#'+REFreg[0]).value, $w('#'+REFreg[4]).value,{
contactInfo: {
"firstName": $w('#'+REFreg[1]).value,
"lastName": $w('#'+REFreg[2]).value,
}
})
.then(async(result)=>{console.log("Update-Contact running...")
let userStatus = await result.status; console.log("User-Status: ", userStatus)
let userID = await result.user.id; console.log("User-ID: ", userID)
//--------------------------------
await updateUserFields(userID, $w('#'+REFreg[1]).value, $w('#'+REFreg[2]).value, uploadAvatarUrl)//, email, avatarURL);
//--------------------------------
await updateContactData(userID, uploadAvatarUrl);
setTimeout(()=>{show_LogIn();},100)
})
.catch((err)=>{let errorMsg = err; console.log(errorMsg);
msg[0] = "";
msg[1] = "!!! E-Mail already registered !!!";
msg[2] = "Please change E-Mail.";
msg[3] = "";
msg[4] = "Forgot password ?";
$w('#boxInfo').style.backgroundColor=colorInvalid, show_infoMessage();
})
}
else {console.log("Avatar-Setup running...")
$w('#boxInfo').style.backgroundColor=colorInvalid
msg[0] = "!!! ATTENTION !!!";
msg[1] = "Avatar-Setup incomplete!";
msg[2] = "Choose your AVATAR please.";
msg[3] = "";
msg[4] = "Possible AVATAR-Formats ---> png/jpg/gif";
show_AvatarSetup(), show_infoMessage();
}
}
The only thing you have to understand, is that after registration your redirection won’t work, because you automaticaly are throwing into a log-in-process.
So this one could help you out…
https://www.wix.com/velo/reference/wix-users/onlogin
Place your redirection code there.