Wix IDE code not adding user IDs to collection on registration

Hi,

I’m trying to write code in the Wix IDE that adds a new user’s ID to a specific collection in a specific field as a text string whenever a new user registers. However, the code isn’t performing this action. Can anyone help identify where the issue might be?

Here’s the code I’m using:

import {members} from 'wix-members-backend';
import wixData from 'wix-data';

export function wixMembers_onMembersCreated(event){
    let userId = {
      "_id": event.metadata.id.toString()
    };
    wixData.insert("eebiba8cabf",userId);
}

 

The collection ID I’m trying to add to is “eebiba8cabf”. I’m not receiving any error messages, but the user ID isn’t being added to the collection. Any suggestions on what might be going wrong?

Thank you in advance for your help!

The function name should be wixMembers_onMemberCreated but the one in the code has onMembers. Also make sure this code is in the proper events.js backend file.