Hi, I have a Dynamic “Events” page that I manually add events to via a repeater but I am wanting to make a “create an event” link to the site, that allows registered site users to add events to the specified database that it’s linked to.
I know how to to this, however, when the logged in registered member posts this event as a Draft (for admin approval), I want it to automatically add their logged in username to the events database on submission so I know who has added it as it currently doesn’t do this… I don’t want them to be manually able to add it, I want it auto added as they could enter any name.
Any idea’s? Thanks!
Martin
Hi @info2stepdesigns ,
You can consider using Reference Fields to PrivateMembersData to map the user that does the action.
You can modify the item before insert with the context object given.
Does it works?

How do you mean use reference field to map the user that submits the form?
I added a Reference field to my “Events” collection to the privatemembersdata collection but not sure how to implement this on the form so that when the user clicks submit (I have a custom onclick submit button to do numerous functions on clicking.
I just don’t know how to get that users’ name who submitted the form to be included in a Field in the database automatically without their input. Really struggling with this one.
I managed to do it using this:
import wixUsers from ‘wix-users’;
$w. onReady(() => {
$w(‘#dataset1’) . onReady(() => {
if (wixUsers. currentUser . loggedIn) {
let userId = wixUsers. currentUser. id;
$w(‘#dataset1’). setFieldValue(‘Postedbymember’, userId);
}
})
});
(I had to add spaces between the statements as on here it thought I was posting links to a site)
What i did was create a Field in my database Collection called “Postedbymember”, and added a Reference field to PrivateUserData".
Added the code to the Form’s submission page, and when they fill out the form and submit, it also adds there userID into the Field I created…
Then, in the Events (all) page that the form has submitted to, inside my repeater I have a single text box not connected to anything stating “Posted by” and then another text box connected to the database Events and text connected to “Postedbymember” - I can select which bit of information to display about the member that posted (Either Email / Name / ID etc) which is selectable now as it is Referenced to the PrivateMemberData collection…
Same goes for the Events (Title) page… Just added the above text boxes and it will display whatever information connected to “Postedbymember” field that has been selected in the API’s text-connection bit.
All good!
EDIT: I do know that WixUsers has now changed over to Wixmembers or something like that but at the moment WixUSer statement is working fine.