Create new line of data in CMS when user signs up

I have a CMS - “Members”. Inside this CMS I have 5 fields: “title”, “userid_members”, “email_members”, “firstname_members”, “lastname_members”.

I want to create a new line in this CMS to be created, with “userid_members” filled with the Account ID; “email_members” filled with user’s email address, “firstname_members” filled with first name and “lastname_members” with user’s lat name.

I have “memberEvent.js” file in the backend files:

// memberEvents.js (folder Backend)
import wixData from "wix-data";

export function memberEvents_onMemberCreated(event) {
  const { _id, loginEmail, firstName, lastName } = event.member;
  
  return wixData.insert("Members", {
    userid_members: _id,
    email_members: loginEmail,
    firstname_members: firstName || "",
    lastname_members: lastName || ""
  })
  .then((item) => {
    console.log("New record 'Members':", item);
  })
  .catch((err) => {
    console.error("Error:", err);
  });
}

My problem is when a new user signs up, nothing shows up in my collection “Members”.

  1. Your Members collection contains only fields that already exist in Wix’s default Member collections - So… Why do you need it?

  2. This is supposed to be in the file backend/events.js

There will be more fields. :slight_smile:

Makes sense. The code looks fine, I gather it’s just the filename

I changed the file name to events.js but still nothing appears in my CMS

When I changed the trigger to button click and moved the code to front-end, everything worked, but when the code is in event.js in backend and the trigger is new registration, it doesn’t work

Check the site logs to see if the logs you made appear after registration, or if the event is not fired at all