# Enable Members to Delete Their Own Accounts Directly from the Members Area Without Contacting Site Owners

**URL:** <https://forum.wixstudio.com/t/enable-members-to-delete-their-own-accounts-directly-from-the-members-area-without-contacting-site-owners/71327>\
**Category:** Show and tell\
**Tags:** wix-auth, wix-location-frontend, wix-members-area, code\
**Created:** [June 4, 2025, 2:15pm UTC](https://forum.wixstudio.com/t/enable-members-to-delete-their-own-accounts-directly-from-the-members-area-without-contacting-site-owners/71327 "2025-06-04T14:15:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrian](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andrian/32/80878_2.png) [@Andrian](https://forum.wixstudio.com/u/Andrian)\
**Post date:** [June 4, 2025, 2:15pm UTC](https://forum.wixstudio.com/t/enable-members-to-delete-their-own-accounts-directly-from-the-members-area-without-contacting-site-owners/71327/1 "2025-06-04T14:15:37Z")

</div>

**Introduction:**  
Hello, I recently encountered a situation where it was necessary to provide users with the option to delete their accounts from the members area without needing to contact the website owner.

I found that this is a [feature request](https://support.wix.com/en/article/site-members-request-allowing-members-to-delete-their-own-accounts), so I decided to implement a solution using Velo.

**To provide a better experience, here is a video demonstrating how to implement this solution step by step. You can watch it here: [link](https://youtu.be/vlC-_rv4HjY)**

**Steps**

1. Enable the developer mode, the instructions how to enable these can be found via this [link](https://dev.wix.com/docs/velo/articles/getting-started/getting-oriented#enabling-velo).

2. In the backend, create a file: deleteMember.web.js  

And place the following code in the created file.

```javascript
import { webMethod, Permissions } from "wix-web-module";
import { members } from "wix-members.v2";
import { elevate } from "wix-auth";

const elevatedDeleteMember = elevate(members.deleteMember);

export const deleteCurrentMember = webMethod(
  Permissions.SiteMember,
  async () => {
    try {
      const currentMember = await members.getCurrentMember();

      if (!currentMember || !currentMember.member) {
        throw new Error("User not logged in");
      }
      const memberId = currentMember.member._id;

      const result = await elevatedDeleteMember(memberId);

      return result;
    } catch (error) {
      console.error("Failed to delete member:", error);
      throw error;
    }
  }
);

```

1. The final steps involve adding the remaining code and improving the user experience to prevent users from accidentally deleting their accounts.  
a) Create a section in the account settings page in the members area, and add a button labeled “Delete Account.”  
b) Create a lightbox, and inside it, add a button labeled “Confirm Delete Account.”  
c) Connect the Button from the page to open the created lightbox  
d)Add the following code to the lightbox’s code.  
e) Make sure to set the button ID to **deleteButton**.

```javascript
import { deleteCurrentMember } from 'backend/deleteMember.web';
import wixLocationFrontend from "wix-location-frontend";
import { authentication } from "wix-members-frontend";

$w("#deleteButton").onClick(async () => {
  try {
    await deleteCurrentMember();

    setTimeout(() => {
      (async () => {
        await authentication.logout();
        // Change this URL to your homepage domain, so after logout, user will be redirected to homepage
        wixLocationFrontend.to("https://yourWebsiteDomain.com");
      })();
    }, 500);

  } catch (e) {
    console.error(e);
  }
});

```

The outcome for this step should look like this:

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

**If you have any questions, feel free to reply here, will be happy to help!**

**Tools, Documentation and APIs:**

> **[Web Method | Velo](https://dev.wix.com/docs/velo/apis/wix-web-module/web-method)**
>
> Defines a backend function that can be called from the frontend. The webMethod() function is a wrapper used to export functions from backend code that can be called from the frontend.

[https://www.wix.com/velo/reference/wix-web-module/permissions](https://www.wix.com/velo/reference/wix-web-module/permissions)

> **[Delete Member | Velo](https://dev.wix.com/docs/velo/apis/wix-members-v2/members/delete-member)**
>
> Deletes a member. The deleteMember() function returns a Promise that resolves to a member object when the specified member is deleted.

> **[Get Current Member | Velo](https://dev.wix.com/docs/velo/apis/wix-members-v2/members/get-current-member)**
>
> Retrieves the currently logged-in member.

> **[Logout | Velo](https://dev.wix.com/docs/velo/apis/wix-members-frontend/authentication/logout)**
>
> Logs the current member out of the site. The logout() function logs the current member out of the site.

> **[To | Velo](https://dev.wix.com/docs/velo/apis/wix-location-frontend/to)**
>
> Directs the browser to navigate to the specified URL. The to() method navigates the browser to another web page.

---

<div class="post-metadata">

**Author:** ![Gal\_Shapiro\_Siton](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/gal_shapiro_siton/32/113127_2.png) [@Gal\_Shapiro\_Siton](https://forum.wixstudio.com/u/Gal_Shapiro_Siton)\
**Post date:** [December 18, 2025, 2:08pm UTC](https://forum.wixstudio.com/t/enable-members-to-delete-their-own-accounts-directly-from-the-members-area-without-contacting-site-owners/71327/2 "2025-12-18T14:08:57Z")

</div>

If you suspect this line is important, that’s on you.
