Problem with user input (email) in custom registration. [Solved]

Hi!

I thought you guys might know the answer, but I´m having a problem in creating custom user registration form. I created string for registration from the fields i want info. The problem is, the user input “email” doesn´t apparently recognize email adresses. Does anyone know solution for the problem?


after i fill in the form, it says:
Wix code SDK error: The registrationOptions parameter that is passed to the register method cannot be set to the value test123@gmail.com. It must be of type object.
Line11

Does anyone know what´s causing the error

This is the code which I have used for my own custom signup lightbox and it all works.

This works perfectly and closes after registering details before returning to home page, then both names will be saved in contacts and once site member is approved the member details will be added to ‘members’ database.

Add your bits to it and see if it works for you.

import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
    
    $w("#registerButton").onClick( (event) => {
        
   let email = $w("#email").value;
   let password = $w("#password").value;
   let first = $w("#firstName").value;
   let last = $w("#lastName").value;

   wixUsers.register(email, password, {
       contactInfo: {
        "firstName": $w('#firstName').value,
        "lastName": $w('#lastName').value,
       }
      } )
      .then( (result) => {
        let resultStatus = result.status;
  wixWindow.lightbox.close();
  wixLocation.to("/main-page");  //Change the URL ending to whatever page you want to send the user to after they log in.
      } );     
    } );
    
});

Hi!

Thanks for the help, now the error codes are gone. Only problem is, when pushing register button nothing happens, and i don+t get any kind of error code at all.

Can you post your updated code Niko?

Are you using this line as it is:

   $w("#registerButton").onClick( (event) => { 

As if you are then you will need to make sure that your button element is actually called #registerButton too and you do not need to have the onClick on in properties either.

Let us see your code and we can see where you are having issues again and make sure that all your values in your code match up to the actual names on your form itself.

Finally, just a thought, are you using a lightbox for that custom register form? (hence the ‘x’ in the top right had corner.)

As if you are you might be using the lightbox own ‘close’ button instead of adding your own button.

Check your lightbox settings and make sure that the option for lightbox close button is turned off and only have the ‘x’ to close it turned on.

Then add your own button and setup as you have already got yours on page and call it as #registerButton.


The elements are:

  1. User Input (email) id: email
  2. User Input (password) id: password
  3. User Input (text) id: firstName
  4. User Input (text) id: lastName
  5. Button id; registerButton

Although my code below should work, if it does not it will show you in your Dev Console the error its throwing. Try

wixUsers.register($w("#email").value, $w("#password").value, {
 "contactInfo": {
   "firstName": $w("#firstName").value,
   "lastName": $w("#lastName").value
    }
  } )
  .then( (result) => {
     let status = result.status;
      wixLocation.to('/aikuiset');
  } )
  .catch( (err) => {
    console.log(err);
  } );
}


Hi!

I edited my code with your help, and now it looks like this:

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

export function registerButton_click(event) {
let email = $w(“#email”).value;
let password = $w(“#password”).value;
let first = $w(“#firstName”).value;
let last = $w(“#lastName”).value;

wixUsers.register($w(“#email”).value, $w(“#password”).value, {
“contactInfo”: {
“firstName”: $w(“#firstName”).value,
“lastName”: $w(“#lastName”).value
}
} )
.then( (result) => {
let status = result.status;
wixLocation.to(‘/aikuiset’);
} );
}

And somehow it works like a charm!

Thank you all for your help!

That is good news you have now got it all to work, thumbs up!