Hi there. I've been trying to create a registration form by following the instructions and example provided at https://support.wix.com/en/article/wix-code-tutorial-creating-a-custom-registration-form-with-code . The user input form page I'm working on is currently at https://scottoffline.wixsite.com/homepower/copy-of-contact-1
Very new to JS, I quickly hit a wall and asked a developer friend (who's not a Wix user) to review the code. He/We came up with the following code. I've cleared the errors (I think), but it still isn't working.
Any suggestions or troubleshooting help is greatly appreciated. Thanks in advance.
Scott
import wixUsers from 'wix-users'; $w.onReady(function () { $w('#button1').onClick( () => { let email = $w('#input3').value; let password = $w('#input4').value; let radioGroupSelection; const selectionValue = $w('#radioGroup1').value; //determine mailing selection if (selectionValue === "Both") { radioGroupSelection = "Home Power and its partners"; } else if (selectionValue === "HP") { radioGroupSelection = "Just Home Power"; } else if (selectionValue === "None") { radioGroupSelection = "No thanks"; } else { radioGroupSelection = "something went wrong if we got this far"; } // register as member using form data wixUsers.register(email, password, { "contactInfo": { "firstName": $w('#input1').value, "lastName": $w('#input2').value, "email": [$w('input3').value], "labels": [radioGroupSelection], //still part of options hash passed into register function along with email and // pw params, but we can't use a number here due to the value of selectionValue // coming from the radio group selection, which is gonna be a string. "selectionValue": $w('#radioGroup1').value } }).then( (result) => { let status = result.status; // "Active" let user = result.user; }); }); });
Try removing "labels"
This is my code for my own custom signup lightbox:
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. } ); } ); });
This works perfectly for me and closes after registering their 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.
Try using my code and adding your parts to it and see if you can get it to work then.