I’m having trouble with
In a site of puzzles’ swap, I have a collection “membres” when I store all recorded members, with some calculated fields (number of puzzles, …).
Working in
Wix Editor
Site link
What I’m trying to do
When a new member registers, it is necessary to create a new item in my collection “membres”, because he is going to add a new puzzle right away.
What I’ve tried so far
I have added this in the velo section :
import wixData from “wix-data”;
$w.onReady(function () {
})$w(‘#registerButton’).onClick((event) => {
let newMember = {
mail: $w(‘#input2’).value.toLowerCase(),
};
wixData.save("membres", newMember);
})
I’d double check the id of the collection. You currently have members which seems like it might be a typo?
Are they being registered as Site Members? If so, I’d recommend running this as a backend event (probably wixMembers_onMemberCreated) - this way the item is only created when the member is actually created, and you don’t have to handle it on the frontend checking if the member was created/then saving etc.