New Member Registration - Email address is not being stored in the database

Hi Juanita:

Something to consider is that your query to test for a previously created record does this:

return wixData.query("Profile")
 .eq("_id", userId)
 .find(); 
} ) 
.then( (results) => {
 // if an item for the user is not found
  if (results.items.length === 0) {

If you need your membership records to be unique based on email address [I would :-)] so your email address is a unique data collection key which you should (as you have already ascertained) check for not the _id. So your code needs to be as follows. This will prevent multiple records being added with the same key email address.

return wixData.query("Profile")
 .eq("email", userEmail)  <------------- ensure unique use of email
 .find();
 } ) 
 .then( (results) => { 
  // if an item for the user is not found
  if (results.items.length === 0) {

Now the other problem that exists with the wix CRM is that it allows multiple records with the same email address. If you use wix-crm to create a contact and wix-users to register and log in then you will get two records with the same email. If you record the id created by wix-crm.createContact it will not be the same one generated by wix-users.register(). The id you need to record for log in purposes is the one from the register() function. Now the only way to send a triggered email when the user is NOT logged in is using the wix-crm.emailContact function not wix-users.emailUser. What this means is that you also need the id from wix-crm.createContact so you need to track both id’s in your user “Profile” data collection and use the correct one for the specific purpose you have in mind.

I hope this makes sense.

Take a look at this thread that dealt with a similar issue.