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
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
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"; /* 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?