# Deleting a member

**URL:** <https://forum.wixstudio.com/t/deleting-a-member/70961>\
**Category:** Ask the community\
**Tags:** wix-data, question, code, wix\
**Created:** [May 17, 2025, 9:48am UTC](https://forum.wixstudio.com/t/deleting-a-member/70961 "2025-05-17T09:48:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![user3410](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@user3410](https://forum.wixstudio.com/u/user3410)\
**Post date:** [May 17, 2025, 9:48am UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/1 "2025-05-17T09:48:31Z")

</div>

**Question:**  
hello everyone,

I have a little problem, which, I suppose can be solved here.  
I have a page where I can add new contacts. That works great, no pb.  
The pb is that they are automatically save as members also. I don’t want that : only a contact NOT a member.

1/ is there a way to save them only as a contact? (Note as member)  
2/ How to delete this member in velo code?

**Product:**  
Wix Editor

\*\*What have you already tried:

> import { authentication } from ‘wix-members-frontend’;  
> import {session} from ‘wix-storage’;  
> import wixData from ‘wix-data’;  
> import wixUsers from ‘wix-users’;
> 
> let emails = ;
> 
> $w(‘#Register’).onClick((event) =\> {

> // Vérifier si les MDP concordent.  
> if($w(‘#CfrmPassword’).value !== $w(‘#Password’).value){  
> console.log(‘Les MDP ne concordent pas’);  
> $w(‘#Recap’).show();  
> $w(‘#Recap’).html = `
> 
> Attention, vos mots de passe sont différents.Merci de vérifier votre saisie…
> 
> -
> 
> } else {  
> console.log(‘les MDP concordent bien’);  
> $w(‘#Recap’).show();  
> $w(‘#Recap’).html = `
> 
> Enregistrement de vos informations en cours. Merci de patienter, vous serez automatiquement redirigé vers le site …
> 
> -  
> $w(‘#Register’).show()
> 
> const password = $w(‘#Password’).value;  
> const email = $w(‘#Email’).value;  
> emails.push(email);
> 
> let options = {  
> contactInfo: {  
> firstName: $w(‘#PrenomClt’).value,  
> lastName: $w(‘#NomClt’).value,  
> emails: emails,  
> },  
> privacyStatus: ‘PUBLIC’  
> }
> 
> authentication.register(email, password, options)  
> .then((registrationResult) =\> {  
> console.log(‘L enregistrement du nouveau client a bien été validé.:’, registrationResult);  
> console.log('Email client : ', email);
> 
> session.setItem(‘MailClt’, $w(‘#Email’).value);  
> console.log($w(‘#Email’).value)
> 
> })  
> .catch((error) =\> {  
> console.error(error);  
> });  
> }
> 
> ```
> });
> 
> ```

thank you very much for your help

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [May 17, 2025, 4:27pm UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/2 "2025-05-17T16:27:42Z")

</div>

Hi, @user3410 !!

Hmm 🤔, I see. I’m not sure if I fully understand what you’re aiming for, but if you just want to collect “contact information,” I think simply using a “form” element would be enough—you don’t need any code. For example, you can set up a form with input fields for things like name and email address. When users fill out the required fields and click the submit button, they should be registered as a contact. You can check whether they were successfully added from the dashboard. 😇

> **[Wix Forms: An Overview | Help Center | Wix.com](https://support.wix.com/en/article/wix-forms-an-overview)**
>
> With Wix Forms, create fully customizable forms and collect all the info you need to run and grow your business. Add forms directly to your site for lead captur

---

<div class="post-metadata">

**Author:** ![Mairie\_MAILLY\_LE\_CHA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mairie_mailly_le_cha/32/97985_2.png) [@Mairie\_MAILLY\_LE\_CHA](https://forum.wixstudio.com/u/Mairie_MAILLY_LE_CHA)\
**Post date:** [May 19, 2025, 9:48am UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/3 "2025-05-19T09:48:20Z")

</div>

hello

What about this code :

> $w(‘#button44’).onClick((event) =\> {
> 
> const contactInfo = {  
> name: {  
> first: $w(‘#firstName’).value,  
> last:$w(‘#lastName’).value,  
> },  
> emails: [{  
> email: $w(‘#email’).value  
> }]
> 
> ```
> };
> 
> ```
> 
> contacts.appendOrCreateContact(contactInfo)  
> .then((resolvedContact) =\> {  
> if (resolvedContact){  
> displayMessage(“AJOUT OK : Nouveau client enregistré”)  
> $w(‘#Messagetext’).show()  
> }else{  
> displayMessage(“ERREUR : Client n’a pas pu être enregistré”)  
> $w(‘#Messagetext’).show()  
> }  
> console.log(resolvedContact)  
> })
> 
> ```
> .catch((error) => {
> console.error(error);
> });    
> 
> ```
> 
> })

---

<div class="post-metadata">

**Author:** ![user3410](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@user3410](https://forum.wixstudio.com/u/user3410)\
**Post date:** [May 19, 2025, 10:57am UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/4 "2025-05-19T10:57:59Z")

</div>

Hi onemoretime

First of all, thanks for your help.

Of course, this is a solution : my customers still use it on the page 'Reservation" : their informations are directly saved in the contacts collection.

But when I use it on my page (where nobody can cannect apart of me : this is a page wher i create contacts/reservations myself), they are not saved in the contacts collection. I dont see them? For sure the submisson form has bee saved because i View the records in the submissions table, but not in contact list? Why?

So that is why i would like to code this =\> Adding new contact but ONLY A CONTACT, not a member.

---

<div class="post-metadata">

**Author:** ![user3410](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@user3410](https://forum.wixstudio.com/u/user3410)\
**Post date:** [May 19, 2025, 12:21pm UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/5 "2025-05-19T12:21:49Z")

</div>

The code seems to be Ok but nothing in wix contact is save…  
Maybe permissions?

The code i Use:

> $w.onReady(function () {
> 
> $w(‘#EnregistrerContact’).onClick(async (event) =\> {  
> console.log(“Test Contact”);  
> const contactInfo = {  
> name: {  
> first: $w(‘#prenomclt’).value,  
> last: $w(‘#nomclt’).value  
> },  
> emails: [{  
> email:$w(‘#mailclt’).value  
> }],  
> phones: [{  
> tag: “PORTABLE”,  
> countryCode: “FR”,  
> phone: $w(‘#input9’).value  
> }],  
> labelKeys: [  
> “Test ajout nouveau contact”  
> ]  
> };
> 
> ```
> try {
> await contacts.appendOrCreateContact(contactInfo);
> console.error(contactInfo)
> console.log("Contact created with ID:", contactInfo.contactId);
> $w('#IDClient').value=contactInfo.contactId
> } catch (error) {
> console.error(error);
> }
> 
> ```
> 
> });  
> });

here the logs:

 ![This image shows a web development interface including a registration form and source code displayed in an interactive debugger UI. (Captioned by AI)](https://us1.discourse-cdn.com/wix/original/3X/2/b/2bfd46132240c91c6d9518a6c4447260bc176fb1.png)

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [May 19, 2025, 3:46pm UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/6 "2025-05-19T15:46:48Z")

</div>

Hmm 🤔, I’m not entirely sure, but according to the reference for the API you’re currently using (`appendOrCreateContact`), its behavior may vary depending on the state of the user being processed.

> **[Append Or Create Contact | Velo](https://dev.wix.com/docs/velo/apis/wix-crm-frontend/contacts/append-or-create-contact)**
>
> Appends an existing contact or creates a contact if it doesn't exist. The appendOrCreateContact() function returns a Promise

So I was thinking, maybe you could try rewriting it using this backend-based API instead. 🙃

> **[Create Contact | Velo](https://dev.wix.com/docs/velo/apis/wix-crm-backend/contacts/create-contact)**
>
> Creates a new contact. The createContact() function returns a Promise

---

<div class="post-metadata">

**Author:** ![user3410](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@user3410](https://forum.wixstudio.com/u/user3410)\
**Post date:** [May 20, 2025, 5:51am UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/7 "2025-05-20T05:51:31Z")

</div>

yes i tried it also.  
But:  
1/ “wix-web-module” is not recognized? Do i have to create a backend code?  
2/error with “Createcontac”

here the captures:

 ![image](https://us1.discourse-cdn.com/wix/original/3X/0/d/0db44a7159b038ace3113e5a2464aa25be94b9fb.png)

![image](https://us1.discourse-cdn.com/wix/original/3X/3/f/3fe3fe328b9e04a64751108fa8b33c248d571ab6.png)

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [May 20, 2025, 6:09am UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/8 "2025-05-20T06:09:33Z")

</div>

I believe this is a backend-only API, so it needs to be used within backend code. Try placing the function in the backend and then calling it from the frontend. 😎

The error you’re seeing with the web module is likely because you’re importing it in the frontend. The web module is meant to be used in the backend and called from the frontend, so it must be imported within backend code. 🙃

The same goes for the error with `createContact`—it’s happening for the same reason. In short, you’re importing APIs intended for backend use inside frontend code, which is why you’re getting these errors. 😎

To explain in more detail: first, you need to create a `web.js` file in the backend and write code like the example below inside it. Then, you need to call and use that backend function from the frontend, as shown in the example below.

```javascript
// this example is cited from "https://dev.wix.com/docs/velo/apis/wix-crm-backend/contacts/create-contact"

// sample.web.js in backend

import { Permissions, webMethod } from "wix-web-module";
import { contacts } from "wix-crm-backend";

export const myCreateContactFunction = webMethod(Permissions.Anyone, () => {
  const contactInfo = {
    name: {
      first: "Ari",
      last: "Thereyet",
    },
  };

  const options = {
    allowDuplicates: false,
    suppressAuth: false,
  };

  return contacts
    .createContact(contactInfo, options)
    .then((contact) => {
      return contact;
    })
    .catch((error) => {
      console.error(error);
    });
});

```

then…

// in frontend

```javascript
import { myCreateContactFunction } from "backend/sample.web.js";

$w.onReady(function () {

    myCreateContactFunction();

});

```

It can be frustrating when errors appear while you’re writing code, but in fact, those errors are actually quite helpful. They’re the editor’s way of telling you exactly what needs to be fixed—and if you follow the guidance, you’ll definitely be able to solve them.

When you’re facing clear, well-defined errors like this, taking it step by step will likely lead to success. So try to approach it with a lighter mindset—it might go more smoothly than you think. 😇

If this code runs successfully and adds “Thereyet Ari” to your contacts correctly, then you’re almost there—just a few more changes to the code should make everything work. Specifically, you’ll need to update it so that the frontend passes your custom contact-related arguments to the backend for processing. 🙃

---

<div class="post-metadata">

**Author:** ![user3410](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@user3410](https://forum.wixstudio.com/u/user3410)\
**Post date:** [May 20, 2025, 12:48pm UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/9 "2025-05-20T12:48:00Z")

</div>

Thank you so much [onemoretime](https://forum.wixstudio.com/u/onemoretime), for taking the time to look into my problem and explain it to me. Indeed, I’m learning every day thanks to this forum and some active members like you. Thanks again. 😀

It’s Ok, i put the code in the backend (no error anymore, and call it from the frontend : GREAT!!

Last question : As you mentioned, I now need to create the link between my backend and my frontend. 🤔

**Currently, it creates a contact with a well-defined name (“Ari Thereyet”, phones, etc…)**

**I would now like to be able to use the variables contained in my fields in the frontend and assign them to each field (name, phone number, etc.) declared in the backend?**

Do I need to create a function?

Thank you again 👌

 ![The image shows an API documentation page with a "Testing Loop" toggle button and a JSON sample of response data in the function output area. (Captioned by AI)](https://us1.discourse-cdn.com/wix/original/3X/a/f/af28a8884b5a4ff37833ac0c85e03fbc99e92997.png)

Here the code from backend:

```javascript
> import { contacts } from 'wix-crm-backend';
> import { Permissions, webMethod } from "wix-web-module";
> 
> export const myCreateContactFunction = webMethod(Permissions.Anyone, (Prenom, Nom,Email) => {
> 
> const contactInfo = {
> name: {
> first: Prenom,
> last: Nom
> },
> emails: [
> {
> //
> email: Email,
> primary: true,
> tag: "MAIN",
> },
> ],
>     
> };
> 
> const options = {
> allowDuplicates: false,
> suppressAuth: true,
> };
> 
> return contacts
> .createContact(contactInfo, options)
> .then((contact) => {
> console.log("Contact enregistré");
> return contact;
>       
> })
> .catch((error) => {
> console.error(error);
> });
> });

```

And my frontend: (With the variables Prenom, Nom & Email):

```javascript
> $w('#EnregistrerContact').onClick((event) => {
> 
> const Prenom = $w("#input3").value;
> const Nom = $w("#input2").value;
> const Email = $w("#input8").value;
> 
> myCreateContactFunction(Prenom,Nom,Email);
> 
> })

```

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [May 20, 2025, 3:48pm UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/10 "2025-05-20T15:48:02Z")

</div>

I’m glad to hear that it worked! 😁 As you can see, at this point, the `contactInfo` is currently set as a fixed value within the backend code. This is just to demonstrate an example implementation and isn’t something you would typically do in a real scenario. So the goal is to make the `contactInfo` dynamic. 🤔

Simply put, you would create an object like this on the frontend and pass it as an argument to `myCreateContactFunction`. If we consider the simplest scenario without any validation to check whether the values are acceptable, it should work by doing something like this.

```javascript
// in frontend

import { myCreateContactFunction } from "backend/sample.web.js";

$w.onReady(function () {

  const contactInfo = {
    name: {
      first: $w("#firstName").value,
      last: $w("#lastName").value,
    },
  };

  myCreateContactFunction(contactInfo);

});

// in backend

import { Permissions, webMethod } from "wix-web-module";
import { contacts } from "wix-crm-backend";

export const myCreateContactFunction = webMethod(Permissions.Anyone, (contactInfo) => {

  const options = {
    allowDuplicates: false,
    suppressAuth: false,
  };

  return contacts
    .createContact(contactInfo, options)
    .then((contact) => {
      return contact;
    })
    .catch((error) => {
      console.error(error);
    });

```

The basic idea of passing data works as shown here, but as it is, this code lacks many important aspects, such as input validation (what values are accepted or rejected), security considerations, and proper error handling. It might be a good idea to ask an AI like ChatGPT how to refine the code to make it more secure. AI is particularly good at applying standardized best practices, so you can generally trust it to guide you in the right direction. Also, if this function is only meant to be used by you or other administrators, there’s no need to set the `Permissions` to `Anyone` for now.

---

<div class="post-metadata">

**Author:** ![user3410](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@user3410](https://forum.wixstudio.com/u/user3410)\
**Post date:** [May 20, 2025, 4:10pm UTC](https://forum.wixstudio.com/t/deleting-a-member/70961/11 "2025-05-20T16:10:10Z")

</div>

All works perfectly with your help.  
My code above is ok : just the refresh takes a few minutes but no problem 🙂

I will take a look for the security as you told me.

See you soon

Thanks a lot.
