Unique User-ID Submitted with Form

How do I have a unique user-ID submitted with each submission from a form. For example, users may fill out a form multiple times and I want to view all of their submissions by one unique ID?

The only way to do this is to have the user log into your site. Once you have an authenticated user you will have a unique id that you can add to the form submission.

Take a look at this article and see if it helps.

Thanks, you’re on the right track. My form is something users fill out once they’re already a member but I don’t see anything that indicates how to return that ID and put it in a database collection. For instance the users might enter the name of an item they’re collecting and submit and then another item and submit. What I’m looking for is a way for my dynamic page that shows their whole “collection” specific to an user. I tried using /{ID} but it’s unique to each record

OK When the user is logged in you can use the wix-users api to get the user’s id.


Then all you need is a userId field in your data collection.

With this, assuming you are using a dataset for saving the form, all you should need to do is:

import wixUsers from 'wix-users';
$w.onReady(() => {
    $w('#datasetname').onReady(() => {
        if (wixUsers.currentuser.loggedIn) {
            let userId = wixUsers.currentUser.id;
            $w('#datasetname').setFieldValue('userId', userId);
        }
    }

});

Thanks, that’s in line with what I want!!! I’m having issues getting it to work and I noticed a missing parenthesis to close off the onReady. I added that but it seems to still not populate the database with my userID when I test with a logged in member. my dataset was dataset2 and I named the userID column userId in my collection that is associated with the form. What am I doing wrong?

Hi There:

Sorry I gave you a typo. You need to be using currentUser not currentuserin the if() statement.
https://www.wix.com/code/reference/wix-users.html#currentUser

Hii I need your help to generate unique id in wix database like we received id ccc629b6-461b-4be7-96d5-edaf13632220 like that and i need to
657-123-564 like my dynamic
https://www.gazette.international/member-profile/ccc629b6-461b-4be7-96d5-edaf13632220 The URL should be: https://www.gazette.international/ then 9 random digits, like this: https://www.gazette.international/045-768-476

@devmxpertz You can find the answer in one of your other posts of the same question.