Goal: Connect text boxes to database from custom registration to automatically show the users last name and number choice.
Problem: I have connected the database to the page and it works correctly in preview mode (using sandbox manual inputs), but it doesn't work in published mode. If I pull the last name from the PrivateMembersData wix default database, this works on the published page, but I also need the number and other inputs from the registration. I have checked the database permissions and I don't think this is the issue (saw this on a lot of other forums - it is on read only on the targeted page and it's only visible in reading by the author)
What Have I done?
I have created a custom registration connected to the Wix CRM and a database to pull information needed from the sign up page (last name, number, etc.) - SEE CODE BELOW
This code isn't pulling the same ID as the private members data that wix pulls and I think this could be the issue - it also doesn't auto populate an owner ID - could also be the issue
Registration Code:
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("#forgotPassword").onClick((event) => {
wixUsers.promptForgotPassword()
.then(() => {
//
})
.catch((err) => {
let errorMsg = err;
});
});
if (wixUsers.currentUser.loggedIn) {
wixLocation.to("/home"); //Change the URL ending to the page you want to redirect the user if they are already logged in
}
$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) {
let email = $w("#email").value;
let password = $w("#password").value;
let firstName = $w("#firstName").value;
let lastName = $w("#lastName").value;
let owner =
/*let position = $w("#position").value;
let type = $w("#type").value;
let jerseynumber = $w("#jerseynumber").value; */
wixUsers.register(email, password, {
contactInfo: {
"firstName": firstName,
"lastName": lastName,
/*"position": position,
"type": type,
"jerseynumber": jerseynumber*/
}
})
.then((result) => {
$w("#dataset1").save()
.then((item) => {
wixLocation.to("/thankyou"); //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(err);
$w('#emailExists').show(); //This is were we prompt the message to show up again ONLY if there is an error
});
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
}
});
});
Problem is not completely clear. Are you trying to save other user inputs in a collection which is not the Private Members collection and associate them to the user so you can retrieve them at a later point?