Link user profile information to user inputs

Hello Wix Community!

I currently have an interactive order form where a user can request custom products. The information on the products are sent to a Database. I’ll review the requested products to see if I can make them and email a response to my users.

The current users of the site have to make a profile with their email, name, and address. Is there any way their profile information can be attached to their orders so that I don’t have to ask them to put their information in every time they request a custom product?

For example, could I have a column named “user email” that would automatically input the user’s email when they submit an order to the database?

Thank you for your help!!

1 Like

Hi Jack

Yes, this can be done, however you will need to code the submission instead of connecting it through the user interface.

Tiaan

Tiaan,

Thank you for your quick response!

I’ve thrown together what I could with code to retrieve the users email. I understand that wixData.query('orderForm) reviews the orderForm data and the .eq function looks for the information that is equal to the userEmail.

I’d like to change those lines to open the orderForm database and set the email field equal to the userEmail. Please let me know how I can do this.

Thank you for your help!

Jack

Hi Jack

There’s an easier approach… If you already have members’ info in a database, then I’d suggest adding a dataset to the page and changing the settings to show only the current logged in users’ info. Then, add a text element on the page, lets call it ‘textEmail’ and connect it to the email field in the members dataset.

Then, when submitting the form data, simply reference the emailText in your code like this:

import wixData from 'wix-data'; // ... 

export function submitButton_click(event, $w){
let toInsert = { 
"formField1": $w("#input1").value, 
"formField2": $w("#input2").value, 
"email": $w("#textEmail").value 
};  
wixData.insert("orderForm", toInsert)
}

Disconnect the UI submissions, this should work like a charm!

Tiaan

Hi! I’ve been trying for long to implement this feature. But for some reason, it doesn’t work for me. I have one question. What do you mean by “disconnect the UI submissions”?

Thanks in advance.