custom sign up form -An account with this email already exists

Hi ,
I have created custom sign up form by light up box and tested with no problem found, but my question is how to show a message like this " An account with this email already exists " if the email is already registered, assume i created hidden text message how to connect it to the code with database?

my code is :

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;

$w.onReady( function (){

$w('#register').onClick( **function**  (){     

let firstName = $w(‘#fname’).value;
let lastName = $w(‘#lname’).value;
let email = $w(‘#email’).value;
let password = $w(‘#password’).value;

    wixUsers.register(email, password, { 
contactInfo: { 

“firstName”: firstName,
“lastName”: lastName,
}
} )

    .then(()=>{ 
        wixLocation.to('/events-wix');  
        wixWindow.lightbox.close(); 

        }) 

    }) 

}) 

thank you

1 Like

Alaa:

The only way to do this is to maintain the contact information in your own data collection. The CRM API is write only so you cannot read from it to validate the existence of new registrations.

What you need to do is create a data collection that contains the information that you want to monitor. Then when you are asked to register the user information you can first try to get a matching record from your data collection. If there isn’t a match then you can register the user and if successful you can add the user record to your data collection.

Here is an example of this that I put together:

Steve

Hello Steve, Thank you very much for your replay, i think your answer will force me to change alot of things, i have one more last question, assume i have created database collection for the users and contacts can i connect them to wix CRM? that is really so important to me.

Alaa:

Anything you add to users using wix-users.register will create a record in the dashboard CRM. The problem is that you are creating a copy on your web site so if you change information you keep on your web site in the CRM on your dashboard then you will create synchronisation problems. If you are simply using the CRM for sending triggered Emails and shoutOuts then you should be OK. The CRM APIs as they currently exist are write only from your page.

Cheers
Steve

Dear Mr.Steve
Thank you so much, i will look to see what i can do because i really need wix CRM to be worked in simple way…

This reply is now outdated. Now there is access to the members area, and you can check for existing registrations. I posted some code for that here: https://www.wix.com/corvid/forum/community-discussion/prevent-contact-duplicates-in-custom-registration