Search.../

leaveCommunity( )

Removes the currently logged-in member from the site community and sets their profile to private.

Description

When a member's profile is private, they do not have access to the site's Members Area features — such as chat, forum, and followers — and their profile is hidden from other members and site visitors.

Note: If a member leaves the site's community, their content (such as forum posts and blog comments) remain publicly visible.

Note: Only logged-in members can call this function without elevated permissions. To call this function as a different identity, elevated permissions are required.

Syntax

function leaveCommunity(): Promise<LeaveCommunityResponse>

leaveCommunity Parameters

This function does not take any parameters.

Returns

Member profile.

Return Type:

Promise<
LeaveCommunityResponse
>
NAME
TYPE
DESCRIPTION
member
Member

The updated member.

Was this helpful?

Make the currently logged-in member's profile private (export from backend code)

Copy Code
1import { members } from 'wix-members.v2';
2import { webMethod, Permissions } from 'wix-web-module';
3
4export const myLeaveCommunityFunction = webMethod(
5 Permissions.SiteMember,
6 async () => {
7 try {
8 const member = await members.joinCommunity();
9 console.log('Member removed from site community:', member);
10
11 return member;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16 }
17);
18
19/* Promise resolves to:
20 * {
21 * "member": {
22 * "createdDate": "2024-02-22T13:52:00Z",
23 * "id": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
24 * "updatedDate": "2024-02-22T13:52:00.674Z",
25 * "activityStatus": "ACTIVE",
26 * "contact": {
27 * "contactId": "ff20c02e-3d13-4412-9529-d628aa0abc12",
28 * "firstName": "John",
29 * "lastName": "Doe",
30 * "phones": [],
31 * "emails": [],
32 * "addresses": [],
33 * "customFields": {}
34 * },
35 * "contactId": "ff20c02e-3d13-4412-9529-d628aa0abc12",
36 * "lastLoginDate": "2024-02-29T11:40:21Z",
37 * "loginEmail": "johndoe@example.com",
38 * "loginEmailVerified": true,
39 * "privacyStatus": "PUBLIC",
40 * "profile": {
41 * "nickname": "John Doe",
42 * "slug": "johndoe",
43 * "photo": {
44 * "id": "",
45 * "url": "https://example.com/newphoto.jpg",
46 * "height": 0,
47 * "width": 0
48 * }
49 * },
50 * "status": "APPROVED"
51 * }
52 * }
53 */
Make the currently logged-in member's profile private (dashboard page code)

Copy Code
1import { members } from 'wix-members.v2';
2
3export async function myLeaveCommunityFunction(){
4 try {
5 const member = await members.joinCommunity();
6 console.log('Member removed from site community:', member);
7
8 return member;
9 } catch (error) {
10 console.error(error);
11 // Handle the error
12 }
13};
14
15/* Promise resolves to:
16 * {
17 * "member": {
18 * "createdDate": "2024-02-22T13:52:00Z",
19 * "id": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
20 * "updatedDate": "2024-02-22T13:52:00.674Z",
21 * "activityStatus": "ACTIVE",
22 * "contact": {
23 * "contactId": "ff20c02e-3d13-4412-9529-d628aa0abc12",
24 * "firstName": "John",
25 * "lastName": "Doe",
26 * "phones": [],
27 * "emails": [],
28 * "addresses": [],
29 * "customFields": {}
30 * },
31 * "contactId": "ff20c02e-3d13-4412-9529-d628aa0abc12",
32 * "lastLoginDate": "2024-02-29T11:40:21Z",
33 * "loginEmail": "johndoe@example.com",
34 * "loginEmailVerified": true,
35 * "privacyStatus": "PUBLIC",
36 * "profile": {
37 * "nickname": "John Doe",
38 * "slug": "johndoe",
39 * "photo": {
40 * "id": "",
41 * "url": "https://example.com/newphoto.jpg",
42 * "height": 0,
43 * "width": 0
44 * }
45 * },
46 * "status": "APPROVED"
47 * }
48 * }
49 */