Hello Brett,
Yea here is how to do it:
- Get current user email
- Query collection you are storing all the contacts in for that email
- If query returns something prevent registration(Redirect to another page, show error message, etc…)
- If query did not return something, insert into collection normally
Here is a template of how to do it with code:
import wixUsers from 'wix-users';
// ...
let user = wixUsers.currentUser;
user.getEmail()
.then( (email) => {
let userEmail = email; // "user@something.com"
wixData.query('YourCollectionName')
.eq('emailField', userEmail)
.find()
.then((res) => {
if(res) {
return console.log('Duplicate user found, returning');
//add error message to show or redirect here
}
//insert to collection here (no duplicate found)
})
} );
Hope this helps,
Majd