Search.../

unassignBadge( )

Removes site members from an assigned badge.

Description

The unassignBadge() function returns a Promise that resolves when the specified members are removed as holders of the specified badge.

The badgeId parameter must be an ID from your site's Members/Badges collection. Typically, you retrieve the ID from the collection using a query or through a dataset.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function unassignBadge(_id: string, memberIds: Array<string>): Promise<void>

unassignBadge Parameters

NAME
TYPE
DESCRIPTION
_id
string

Badge ID.

memberIds
Array<
string
>

List of members to remove.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Remove assigned badge from member.

Copy Code
1import { badges } from 'wix-members.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample _id value: '215be5d9-4b32-4861-9eb5-2152930dd0b4'
5 *
6 * Sample memberIds value:
7 * [
8 * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32',
9 * 'a1b2c3d4-e5f6-7890-1234-56789abcdef0',
10 * 'f0e1d2c3-ba98-7654-3210-fedcba987654'
11 * ]
12 */
13
14export async function myUnassignBadgeFunction(_id, memberIds) {
15 try {
16 const elevatedUnassignBadge = elevate(badges.unassignBadge);
17 const unassignedMembers = await elevatedUnassignBadge(_id, memberIds);
18
19 console.log('Success! Created/updated result:', unassignedMembers);
20 return unassignedMembers;
21 } catch (error) {
22 console.error(error);
23 // Handle the error
24 }
25
26}
27
28/* Promise resolves to void */