I’m having some issues. I created a sign up page, and form. I followed all the instructions in the YouTube video on how to do this from Wix. Everything worked fine, and while playing around with the Sign Up form, I realized a person can create the same account multiple times. So I searched for some codes to prevent this. And I found this code:
import wixData from ‘wix-data’;
export function users_beforeInsert(item, context) {
let p = new Promise(function(resolve, reject)
{
//create a query to look for items with the same name as the item we’re tring to insert
let username_q = wixData.query(“users”).eq(“username”, item.username);
//create a query to look for items with the same email as the item we’re tring to insert
let email_q = wixData.query(“users”).eq(“email”, item.email);
//create a query to look for items with the same name OR the same email as the item we’re trying to insert
let big_q = username_q.or(email_q);
//run the query to count the number of items that match
big_q.count().then(count =>
{
if (count === 0)
{
resolve(item);
}
else
{
reject("count is more than 0, dups found!");
}
});
});
//return the promise from the hook
return p;
}
Upon implementing this code, everything worked fine! While in Sandbox Mode/Preview Mode, the form works perfectly. New unique users can sign up, and if they try and sign up more than once, it is refused. So everything worked great! BUT…when I saved my work and published the page, I went to the LIVE site to try out the form on the LIVE site. Well, that’s where the issue is. On the LIVE site, the form just sits there. AND nothing gets sent to the database to be stored. However, when in Preview mode/Sandbox Mode everything works like it is supposed to. Any help please? I’m kind of at a stand still right now…