User Input Forms for Members

I have a question regarding user input forms, more specifically, user input forms for members of the website. What I want to do is create a form where members can fill out data that is sent to a created database. That part is not where I’m having trouble, where it gets tricky for me is I don’t want each member having to input their own username/name when filling out the form. I don’t want each member to do this because this form would be on their ‘members page’ where I think filling out their username/name on a form seems unnecessary. In other words, when the member fills out the form, I want their username/name automatically sent to the created database so the admin, me in this case, can see what member filled out which data. I’ve tried turning the ‘Owner’ field on in the created database, but the ‘Owner’ field gives me a bunch of random numbers I don’t understand and does not help me in understanding which member filled out the form. I’ve tried to look on the support page for help on this specific problem with no luck. I would appreciate your feedback in solving this situation, thanks!

Did you already have searched for “PrivateMembersData” here in this forum?
Or for “currentUser” ? Or for “eMail” ?

You may need something like…

console.log(wixUsers.currentUser.id)

or…

console.log(wixUsers.currentUser.getEmail())

So if it is only logged in site members who are filling in this form, then why not simply set up a read only user input and use that to get the users info.

You can have this input shown on your screen and it will not be accessible, or you can simply set it to be hidden on load in the properties panel.

You can use code like ‘getCurrentItem()’ to get the users item from that specific field.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#getCurrentItem

Then you will have to save the value using code such as ‘setFieldValue’ to save the input into your dataset.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValue

You won’t need to use the save() function if you have a submit button on your form.

You can see a basic example of this here.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-AUTO-FILL-FORM-WITH-USER-INPUTS

Thanks for replying! I tried following along with the example you provided at the end, but the example only connected one static name. I want to connect the member’s name when a member fills out the form for each member. In other words, the member’s name will not be static since there are multiple members with different names.

Am I able to connect data from the ‘privatemembersdata’ database to another database, specifically the database where I have the members fill out the form? If so, how would I be able to do that?

Once again, thanks for your input!

Thanks for your input!

How would I connect ‘currentUser’ information to a database?

I’m unfamiliar with the console function and what it does.

If the member is logged in then you can just use the Wix Members app collection to get the current item.

You will just need to use set field value afterwards to set it to save in the other dataset field of where you are saving it.

You can also simply just connect a text box to the specific field in the Wix Members app collection.

As member is logged in the shown text value will be specific to that user only.

Then simply use the set field value code and save it with your submit button.

To add a dataset to your page see here.
https://support.wix.com/en/article/adding-and-setting-up-a-dataset

I’m familiar with making a database. Where I’m having trouble is connecting member information (such as their name) to the database.

Are you referring to the Wix Groups app? I’m having trouble finding the Wix Members app.

You can find out about the Wix Members app here.
https://support.wix.com/en/article/adding-a-members-area-to-your-site

Simply add a dataset element to your page and connect the dataset to the collection from the Wix Members app.

Thanks for the feedback again! The pictures really helped.

When I followed what you did above, the ‘first name’ that appears was a different member’s first name than my member’s first name. How do I get it to display the correct member’s first name when each member visits the page? For instance, when I visit the page it displays “Hank”, whose name is in the PrivateMembersData dataset, instead of my name “Collin”.

When you are using the Wix Users API, you need to be testing the published site only for it to work fully.

If you test this in preview mode you will probably get a list of all your site member names that you can choose from as you are admin.

If I remember right this is shown in the top right corner of your Wix Editor and you can select from the dropdown the specific members name.

For this to work properly, you need to be viewing it on your live site and logged in as a site member yourself.

https://www.wix.com/corvid/reference/wix-users.html
The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

I do not see a dropdown of each specific members name in the top right corner. If I could locate that I’m pretty sure that would solve my problem! Could you possibly send a picture of where that would be?

Also, I did test it on the live site and was logged in as a site member myself, so I’m not sure why it didn’t display my name.

I have it setup on a member profile page which is setup similar to this example.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

So on the members first page which is their profile page, the dataset is connected to the Members collection as in the tutorial and is set to be READ.

All user inputs on this first page are simply connected to the specific fields from the collection and I also have a plain text box at the top of the page that is connected to the first name field from this collection as well.

As the user is already logged in when they view their own profile pages, the collection itself will be filtered already and only take the data of the currently logged in site member.

Therefore the only thing that should appear in the text box is that users first name and it does.

As for the dropdown element, you get this as shown here.

You can select the members name and then if you clicked on preview, it would then take you to the preview mode and show the page of that member, with the dropdown changing to this.

If you don’t have your own dataset, then you can simply use the Wix Members app own Members/PrivateMembersData collection for this and connect the text box to the first name field from this collection.

Just make sure that whatever dataset element you have used for this that you set it to be READ and not write or read and write.