#location #dynamic #page #login
what i'm trying to do is redirect users to their dynamic site
when they register, it's okay, I can send them to their dynamic site
but what it does not do is when they use the (login) button after completing the registration does not work for sending to their dynamic page
i need link must be {name}
Sign up Code (Working)
//// Sign up - to dynamic page///////
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
import wixData from 'wix-data';
let registration;
$w.onReady(function () {
$w("#registrationButton").onClick((event) => {
console.log("Button was clicked"); //You can change the text of this line or delete it
$w('#errorMessage').hide(); //We want to hide all error messages when the person attempts to register again
$w('#emailExists').hide(); //We want to hide all error messages when the person attempts to register again
if ($w("#email").valid && $w("#password").valid && $w("#name").valid && $w("#lastName").valid) {
let email = $w("#email").value;
let password = $w("#password").value;
let name = $w("#name").value;
let last = $w("#lastName").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": name,
"lastName": last
}
})
.then((result) => {
$w("#dataset1").save()
.then((item) => {
wixLocation.to(`/member/${name}`); //URL register
})
.catch((err) => {
let errMsg = err;
});
})
.catch((err) => {
let errorMsg = err;
console.log(err);
$w('#emailExists').show(); //error
});
console.log("Trying to register"); //error
Login Code (Not working)
//// Login - to dynamic page///////
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
import wixData from 'wix-data';
$w.onReady(function () {
});
export function loginButton_click(event) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email, password,)
.then( () => {
console.log("User is logged in");
wixLocation.to(`/member/${name}`); //URL login
} )
.catch( (err) => {
console.log(err);
$w("#errorMessage").show(); ///error
} );
}
Console (Yes I know how to find it)
///Codes I am trying but to no avail///
let ID = $w("#dataset1").getCurrentItem()._id; wixLocation.to(`/member/`+ ID); ///Or/// let ID = $w("#dataset1").getCurrentItem()._id; wixLocation.to(`/member/{ID})`; /// wixLocation.to(`/member/${ID}`); ///Or/// let ID = $w("#dataset1").getCurrentItem()['link-member-all']; wixLocation.to(ID);
You are redirecting with this line of code:
wixLocation.to(`/member/${name}`);//URL login
However, the variable name is not set anywhere in the code.