Hi! I don’t know how to link the PrivateMembersData which have the data: first name, last name, email, password of the current user, to my own database which have the same values: first name, last name, email, password. And that other database which I created has the following permission…
Read: Site member
Create: Site member
Update: Site member author
Delete: Site member author
Hope someone could help me with this one.
By the way, this is the code for my sign up lightbox. As you may notice, I haven’t yet put the code which has the ability to link the data from “PrivateMemberData” to “Member” (my own database)… When a person sign up having this code, it’s working properly, however, I just want to have their name , email addresses and password to be shown in my “Member” database.
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 () {
if (wixUsers.currentUser.loggedIn) {
wixLocation.to(`/member/my-profile/${wixUsers.currentUser.id}`); //Change the URL ending to the page you want to redirect the user if they are already logged in
}
$w("#password").onKeyPress((event) => {
let key = event.key;
$w('#errorMessage').hide();
$w('#emailExists').hide();
if (key === "Enter") {
console.log("Pressed Enter key on Password field"); //You can change the text of this line or delete it
if ($w("#email").valid && $w("#password").valid && $w("#firstName").valid && $w("#lastName").valid) {
let email = $w("#email").value;
let password = $w("#password").value;
let first = $w("#firstName").value;
let last = $w("#lastName").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": first,
"lastName": last
}
})
.then((result) => {
$w("#successful").show();
wixLocation.to("/member/welcome-new-user")
//Change the URL ending to the page you want to redirect the user after they successfully register
.catch((err) => {
let errMsg = err;
});
})
.catch((err) => {
let errorMsg = err;
console.log(errorMsg);
$w('#emailExists').show();
});
} else {
console.log("Some inputs are invalid"); //You can change the text of this line or delete it
$w('#errorMessage').show();
}
} else {
console.log("Did not press Enter key."); //You can change the text of this line or delete it
}
});
$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("#firstName").valid && $w("#lastName").valid) {
registerPerson();
console.log("Trying to register"); //You can change the text of this line or delete it
} else {
$w('#errorMessage').show(); //This is were we prompt the message to show up again ONLY if there is an error
console.log("Missing information"); //You can change the text of this line or delete it
}
});
});
function registerPerson() {
let email = $w("#email").value;
let password = $w("#password").value;
let first = $w("#firstName").value;
let last = $w("#lastName").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": first,
"lastName": last
}
})
.then(() => {
$w("#successful").show();
wixLocation.to("/member/welcome-new-user");
//Change the URL ending to the page you want to redirect the user after they successfully register
})
.catch((err) => {
let errorMsg = err;
console.log(err);
$w('#emailExists').show(); //This is were we prompt the message to show up again ONLY if there is an error
});
}