Registration Code-->Email Verification and CRM sync

Hello guys, somebody could help me?
I would had an email verification when the member register himself and also i would syncronize all the ContactInfo such as City, State, telephone and Address in Wix CRM.Thank you so much.

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixCRM from ‘wix-crm’;

export function button68_click(event) {
$w(“#cognome”).required = true ;
$w(“#Nome”).required = true ;
let label;
let unformattedUserEmail = $w(“#email”).value;
let formattedUserEmail = (unformattedUserEmail).toLowerCase();

console.log(formattedUserEmail); 

//query the user database to ensure the new user email has not been previously been used to register

wixData.query("Account") 

    .eq("email", (formattedUserEmail)) 

    .limit(1) 

    .find() 

    .then((results) => { 

let emailPreviouslyRegistered = results.totalCount
let validityObj = $w(“#Nome”).validity;
let validityObj1 = $w(“#cognome”).validity;
let validityObj2 = $w(“#Paese”).validity;
let validityObj3 = $w(“#indirizzo”).validity;
let validityObj4 = $w(“#cap”).validity;
let validityObj5 = $w(“#email”).validity;
let validityObj6 = $w(“#telefono”).validity;
let validityObj7 = $w(“#password”).validity;

        validityObj = { 

            tooShort: 1 

        } 
        validityObj1 = { 

            tooShort: 1 

        } 
        validityObj2 = { 

            tooShort: 1 

        } 
        validityObj3 = { 

            tooShort: 1 

        } 
        validityObj4 = { 

            tooShort: 1 

        } 
        validityObj5 = { 

            tooShort: 1 

        } 
        validityObj6 = { 

            tooShort: 1 

        } 
        validityObj7 = { 

            tooShort: 1 

        } 

if (emailPreviouslyRegistered === 0) {
$w(‘#text62’).hide();
if ($w(‘#checkbox2’).checked === false ) {
$w(‘#text60’).show();
} else {

if ($w(‘#Nome’).valid === true ) {
$w(‘#text60’).hide();
$w(‘#text58’).show();
} else {
$w(‘#text60’).hide();
if ((‘#cognome’).valid === true ) {
$w(‘#text58’).show();
} else {

if (($w(‘#indirizzo’).valid === true )) {
$w(‘#text58’).show();
} else {
if (($w(‘#Paese’).valid === true )) {
$w(‘#text58’).show();
} else {
if (($w(‘#cap’).valid === true )) {
$w(‘#text58’).show();
} else {
if (($w(‘#email’).valid === true )) {
$w(‘#text58’).show();
} else {
if (($w(‘#telefono’).valid === true )) {
$w(‘#text58’).show();
} else {
if (($w(‘#password’).valid === true )) {
$w(‘#text58’).show();
} else {
$w(‘#text60’).hide();
$w(‘#text58’).hide();
wixUsers.register($w(‘#email’).value, $w(‘#password’).value, $w(‘#Nome’), $w(‘#cognome’), $w(‘#Nazione’), $w(‘#indirizzo’), $w(‘#telefono’), $w(‘#Paese’), $w(‘#cap’), {
“contactInfo”: {
“Nome”: [$w(‘#Nome’).value],
“Cognome”: $w(‘#cognome’).value,
“email”: [$w(‘#email’).value],
“Nazione”: $w(‘#Nazione’).value,
“Indirizzo”: $w(‘#indirizzo’).value,
“Telefono”: $w(‘#telefono’).value,
“Città”: $w(‘#Paese’).value,
“Cap”: $w(‘#cap’).value,
“Label”:[“Privato”]
}

                                                    }) 
                                                    .then((result) => { 

let status = result.status; // “Pending”
let approvalToken = result.approvalToken;
let user = result.user; {
$w(‘#text59’).show(‘slide’, SlideOptions);
$w(‘#box4’).hide(‘slide’, slideOptions)

                                                        } 
                                                    }) 
                                            } 
                                        } 

                                    } 

                                } 

                            } 

                        } 

                    } 

                } 
            } 
        }  **else**  { 
            $w('#text62').show(); 
            console.log('Email già usata') 
        } 
    }) 

}

UPP!Help please!

did you get this working yet? I am trying to do the same thing but can’t write to the CRM fields for address, city, state, zip or phones. I had to create custom fields called homeCity, homeState, etc, to workaround but it still leaves the default CRM fields blank, which is annoying.

Please somebody can help me?

Check out the Users API here . Search for " Register a user sending an email for confirmation " for explanation about it.

Thanks, I saw it but I didn’t understand very well how to send the email, because it doesn’t work for me,Should I use SendGrid?

@fraspace5

Have a read of these forum posts:

I’ve used SendGrid on my site and it all works fine, however I use it for the triggered email option in the tutorial linked below and not for registering new members.

Although note that anybody who fills in and submits the form that the triggered email is for, they do actually get saved into my contacts list with all the custom fields filled in too.

You can see if you can incorporate the wix user register code from the wix code api section and both tutorial codes for sending triggered email to your new member registrations.

If you are wanting to use another company instead, then you will have to modify your code to work with them instead.

I followed this tutorial:

If you need more help here is a youtube video which takes you all through it:

And incorporated some of the code from this tutorial too for creating new contact part:

If you do use SendGrid, then I suggest you setup domain and sender authentication too.

@givemeawhisky i know how to set Sendgrid, but i didn’t understand if the page where users confirm their registration is a dynamic page. Should be?