We created a custom membership form that was not working properly, allowing you to skip through the form without filling out required fields, and even if you did fill them out and signed up, it would not register any information.
Fast forward, someone responded to the forum post regarding this original problem, providing the necessary code:
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#signup').onClick( () => {
let participatingagent = $w("#participatingagent").value
let email = $w("#email").value
let redidagent = $w("#redidagent").value
let officephone = $w("#officephone").value
let fax = $w("#fax").value
let participatingfirm = $w("#participatingfirm").value
let agentcell = $w("#agentcell").value
let redidoffice = $w("#redidoffice").value
let address = $w("#address").value
let password = $w("#password").value
let upload = $w("#uploadbutton").value
wixUsers.register(email, password, {
"contactInfo": {
"participatingagent": participatingagent,
"participatingfirm": participatingfirm,
"redidagent": redidagent,
"redidoffice": redidoffice,
"agentcell": agentcell,
"officephone": officephone,
"fax": fax,
"address": address,
}
})
.then((result) => {
wixLocation.to('/plans-pricing');
});
});
});
Now, when you go to the form, the required fields need to be filled out, and registration goes through when you sign up. However, it is not capturing all the data in the Contact List. The necessary fields are there (each field was synced with Contacts), however most of them are blank, even after filling them out during registration.
The "PrivateMembersData" database does not work because it does not match with the fields in our custom registration form, but it does log the info that we do have in the form that matches with the database (e.g. email, phone, etc.) Is there specific script that needs to be added to this database to change the database fields properly?
Is there a way we can edit these fields to match our registration form? We also created a separate database with the same titles of the fields in the registration form. If so, how do we connect it/replace the "PrivateMembersData"? Not sure which approach to take, if either of these are the way towards the solution, but would appreciate guidance on this!
Whatever you include in your register form is what gets collected.
See the register api and 'Register a user as a site member with registration options' for more info.
https://www.wix.com/corvid/reference/wix-users.html#register
These are the fields that you can use to collect registration info in the Wix PrivateMembersData collection when users first register.
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields
If you want more info, then you can create your own members dataset and each member can have their own profile page which can be updated with whatever user inputs you want.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
This is my own sign up lightbox code which works perfectly and closes after registering details before moving user onto signup status page, then both names will be saved in contacts and once site member is approved the member details will be added to 'members' database (which I have added as a separate dataset similar to the example in the building your own members area tutorial above).
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("/sign-in-status"); //Change the URL ending to whatever page you want to send the user to after they log in. } ); } ); });
You can add custom fields to your contacts.
https://support.wix.com/en/article/adding-custom-fields-to-contacts
Plus you can create a new contact without registering the user by viewing the create contact example below, which would need the Wix crm import at the top of your code..
https://www.wix.com/corvid/reference/wix-crm.html#createContact
The create contact is something I have done on my own website after a user has submitted a user input form with an on after save hook, which runs first and gets the values before entering them into my contacts and then sending my triggered email afterwards.
import wixCRM from 'wix-crm'; $w.onReady(function () { $w("#JoinUsForm").onAfterSave(() => { let startDate = $w("#startDate").value; let firstName = $w('#firstName').value; let lastName = $w('#lastName').value; let email = $w("#email").value; let choirRole = $w("#choirRole").value; let readMusic = $w("#readMusic").value; let choirBefore = $w("#choirBefore").value; let startNow = $w("#startNow").value; wixCRM.createContact({ "firstName": firstName, "lastName": lastName, "emails": [email], "Choir Role": choirRole, "Read Music": readMusic, "Choir Before": choirBefore, "Start Now": startNow, "Start Date": startDate }) .then((contactId) => { // Need to use the triggered email name return wixCRM.emailContact('joiningusform', contactId, { "variables": { // Need to use the triggered email variable names "firstName": firstName, //"lastName": $w('#lastName').value, << - not defined in the triggered email "email": email, "choirRole": choirRole, "readMusic": readMusic, "choirBefore": choirBefore, "startNow": startNow, "startDate": startDate.toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'}) } }); }) .catch((err) => { // handle the error if the email wasn't sent console.log(`Error: ${err}`); }); }); });
As @givemeawhisky wrote, you need to first define your members custom fields: https://support.wix.com/en/article/adding-custom-fields-to-contacts. Then the additional fields you send as ContactInfo on register() will be populated to these fields.
@givemeawhisky @Ohad Laufer,
Custom fields were already added to Contacts. The problem is that when you fill in that information, it is not being captured after you register.
You should make sure that the custom fields' types are set properly. Also, in order to set their value - use the field name, lower case, with spaces, so, for example, for "Agent Cell Phone" you should use:
"agent cell phone": agentcell
Ohad, this was already done. Still not working
Try something like this and make sure that you use the correct code in your original post too as you are missing ; on some lines and you have contact info enclosed in "".
import wixUsers from 'wix-users'; import wixWindow from 'wix-window'; import wixLocation from 'wix-location'; $w.onReady(function () { $w(“#signup”).onClick( () => { let participatingAgent = $w("#participatingagent").value; let email = $w("#email").value; let redidAgent = $w("#redidAgent").value; let officePhone = $w("#officePhone").value; let fax = $w("#fax").value; let participatingFirm = $w("#participatingFirm").value; let agentCellPhone = $w("#agentCellPhone").value; let redidOffice = $w("#redidOffice").value; let address = $w("#address").value; let password = $w("#password").value; let upload = $w("#uploadButton").value; wixUsers.register(email, password, { contactInfo: { "Participating Agent": participatingAgent, "Participating Firm": participatingFirm, "Redid Agent": redidAgent, "Redid Office": redidOffice, "Agent Cell Phone": agentCellPhone, "Office Phone": officePhone, "Fax": fax, "Address": address } }) .then( (result) => { let resultStatus = result.status; wixWindow.lightbox.close(); wixLocation.to(“/plans-pricing”); }); }); });
@givemeawhisky thank you!
I owe you a whisky! ;-)