Question:
When registering a new member with an email that doesn’t exist in the member table, it is shows “A member with this email address already exists. Try a different email.” when the verification code popup is shown.
In the browser console, I have:
Failed to load resource: the server responded with a status of 409 () register:1
identity email Already exists siteMembersSdkFactory.ts:259
Product:
Wix Editor Custom Sign Up
What are you trying to achieve:
Use a custom sign up Lightbox to create new members that also need to set a verification code to pass the sign up page.
What have you already tried:
const email = $w(“#emailInput”).value.trim();
const password = $w(“#passwordInput”).value.trim();
const firstName = $w(“#firstNameInput”).value.trim();
const lastName = $w(“#lastNameInput”).value.trim();
console.log("Registering " + email)
// Check if email already exists
wixData.query("Members/PrivateMembersData")
.contains("loginEmail", email.toLowerCase())
.find()
.then((results) => {
if (results.items.length > 0) {
// Email already exists
$w("#errorMessage").text = "This email is already registered. Please log in.";
console.warn("Email already exists:", email);
} else {
// Proceed with registration
console.log("email doesnt exist" + email)
authentication.register(email, password, {
contactInfo: {
firstName: firstName,
lastName: lastName,
}
})
.then((user) => {
console.log("User registered successfully:", user);
// Insert custom data into collections
const memberId = user.member._id;
const toInsert = { title: memberId };
// Insert into UserWeddingInfo
wixData.insert("UserWeddingInfo", toInsert)
.then(() => console.log("UserWeddingInfo record added"))
.catch((err) => console.error("Error inserting UserWeddingInfo:", err));
// Insert into MembersInspo
wixData.insert("MembersInspo", toInsert)
.then(() => console.log("MembersInspo record added"))
.catch((err) => console.error("Error inserting MembersInspo:", err));
// Insert into MembersBudget
wixData.insert("MembersBudget", toInsert)
.then(() => console.log("MembersBudget record added"))
.catch((err) => console.error("Error inserting MembersBudget:", err));
// Insert into MembersTask
wixData.insert("MembersTask", toInsert)
.then(() => console.log("MembersTask record added"))
.catch((err) => console.error("Error inserting MembersTask:", err));
// Redirect to the profile page after successful insertions
wixLocation.to("/memberprofile");
})
.catch((err) => {
console.error("Error during registration or data insertion:", err);
$w("#errorMessage").text = "An error occurred during signup. Please try again.";
});
}
})
.catch((err) => {
console.error("Error querying members data:", err);
$w("#errorMessage").text = "An error occurred. Please try again.";
});
This is currently my code.