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. (dashboard page code)
Copy Code
1import { badges } from 'wix-members.v2';23/* Sample _id value: '215be5d9-4b32-4861-9eb5-2152930dd0b4'4 *5 * Sample memberIds value:6 * [7 * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32',8 * 'a1b2c3d4-e5f6-7890-1234-56789abcdef0',9 * 'f0e1d2c3-ba98-7654-3210-fedcba987654'10 * ]11 */1213export async function myUnassignBadgeFunction(_id, memberIds) {14 try {15 const unassignedMembers = await badges.unassignBadge(_id, memberIds);1617 console.log('Success! Created/updated result:', unassignedMembers);18 return unassignedMembers;19 } catch (error) {20 console.error(error);21 // Handle the error22 }2324}2526/* Promise resolves to void */27
Remove assigned badge from member. (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { badges } from 'wix-members.v2';3import { elevate } from 'wix-auth';45/* Sample _id value: '215be5d9-4b32-4861-9eb5-2152930dd0b4'6 *7 * Sample memberIds value:8 * [9 * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32',10 * 'a1b2c3d4-e5f6-7890-1234-56789abcdef0',11 * 'f0e1d2c3-ba98-7654-3210-fedcba987654'12 * ]13 */1415export const myUnassignBadgeFunction = webMethod(Permissions.Anyone, async (_id, memberIds) => {16 try {17 const elevatedUnassignBadge = elevate(badges.unassignBadge);18 const unassignedMembers = await elevatedUnassignBadge(_id, memberIds);1920 console.log('Success! Created/updated result:', unassignedMembers);21 return unassignedMembers;22 } catch (error) {23 console.error(error);24 // Handle the error25 }2627});2829/* Promise resolves to void */
Remove assigned badge from member. (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { badges } from 'wix-members.v2';3import { elevate } from 'wix-auth';45/* Sample _id value: '215be5d9-4b32-4861-9eb5-2152930dd0b4'6 *7 * Sample memberIds value:8 * [9 * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32',10 * 'a1b2c3d4-e5f6-7890-1234-56789abcdef0',11 * 'f0e1d2c3-ba98-7654-3210-fedcba987654'12 * ]13 */1415export const myUnassignBadgeFunction = webMethod(Permissions.Anyone, async (_id, memberIds) => {16 try {17 const elevatedUnassignBadge = elevate(badges.unassignBadge);18 const unassignedMembers = await elevatedUnassignBadge(_id, memberIds);1920 console.log('Success! Created/updated result:', unassignedMembers);21 return unassignedMembers;22 } catch (error) {23 console.error(error);24 // Handle the error25 }2627});2829/* Promise resolves to void */