OnMemberDeleted() - Delete Member Records From Other Collection

Hi Everybody
I am trying to use the below code to delete the item related to the member when this member was deleted from my ‘Members’ collection but it doesn’t work, please help to find where is the problem

I am using the Wix members area and ‘Members’ collection contain additional data with reference field to the ’ PrivateMembersData’ collection

import wixData from'wix-data';  exportfunctionwixMembers_onMemberDeleted(event) {   
const deletionEventId = event.metadata.id;   
const entityId = event.metadata.entityId; wixData.remove("Members", entityId)     
.then(() => {       
console.log("Member record deleted successfully.");     
.catch((error) => {       
console.error("Failed to delete member record:", error);     

When you say “it doesn’t work”, what is happening? What is the response or error you get from your code? Also where are you testing this? Live, preview, functional testing?

I test it on live website, when I delete the member, it doesn’t delete it from the ‘Members’ collection, the member item record will be kept on the data collection