So I have a booking form page with a ‘everyone permission’, after they enter all the information when they click submit button, the user need to log in or register to be a member before the booking form is submit. And after the form is submitted, I can know which member submit it.
If you want to have a database (for form submissions) then set the database permissions to ‘Site Member Only’. This will only allow Site Members to make a submission.
Now there are many creative ways you can prompt user’s to become a site member before form submission. One method is to check whether the user is logged in or not at the time of submission. An example code would be like below.
export function button_click(event) {
if(wixUsers.currentUser.loggedIn === true) {
//allow submission
} else {
authorize();
}
}
function authorize() {
wixUsers.promptLogin()
.then( (user) => {
return user.getEmail();
})
.then( (email) => {
let userEmail = email; //submit email along with the data
})
.catch( (err) => {
let errorMsg = err; //show an error
});
}
Submit the data using Wix Data’s insert() function