unassignBadge( )


Removes site members from an assigned badge.

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.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Badges
Learn more about app permissions.
Method Declaration
Copy
function unassignBadge(_id: string, memberIds: Array<string>): Promise<void>;
Method Parameters
_idstringRequired

Badge ID.


memberIdsArray<string>Required

List of members to remove.

JavaScript
import { badges } from "wix-members.v2"; /* Sample _id value: '215be5d9-4b32-4861-9eb5-2152930dd0b4' * * Sample memberIds value: * [ * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32', * 'a1b2c3d4-e5f6-7890-1234-56789abcdef0', * 'f0e1d2c3-ba98-7654-3210-fedcba987654' * ] */ export async function myUnassignBadgeFunction(_id, memberIds) { try { const unassignedMembers = await badges.unassignBadge(_id, memberIds); console.log("Success! Created/updated result:", unassignedMembers); return unassignedMembers; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?