How to know which site member submit the form

I created a user input form and set permission to site member only but when any site member submitted the from in the database it does not shows who has submitted the form

1 Like

Hi Rishabh,
Some code is required in order to do it.
My suggestion is to use currentUser method.
Add a new field to the item collection with the users relevant information (id / email).
Good luck!
Roi

Hey Roi
Can you provide me the code

Hi,
I can provide you an example.
Add an before insert hook .

import wixUsers from 'wix-users';
export function myCollection_beforeInsert(item, context) { 
    let user = wixUsers.currentUser;
    let userId = user.id;  
    item.userId = userId;
    return item;
}

Good luck!
Roi

I have the exact same requirement but the code above did not work. In preview it gives error that the module wix-users does not exist. Also is it supposed to be user.id.id or user.id.