> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: assignBadge(_id: string, memberIds: Array) # Method package: wixMembersV2 # Method menu location: wixMembersV2 --> badges --> assignBadge # Method Link: https://dev.wix.com/docs/velo/apis/wix-members-v2/badges/assign-badge.md # Method Description: Assigns a badge to site members. The `assignBadge()` function returns a Promise that resolves when the specified badge is assigned to the specified members. 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. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Assign a badge. (dashboard page code) ```javascript import { badges } from 'wix-members.v2'; /* Sample id value: 'd5786246-271d-40d1-bbe5-346244e89799' * * Sample memberIds value: * [ * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32' * ] */ export async function myAssignBadgeFunction(_id, memberIds) { try { const membersIdsWithBadge = await badges.assignBadge(_id, memberIds); console.log('MemberIds with assigned badge: ', membersIdsWithBadge); return membersIdsWithBadge; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "memberIds": [ * "7d368843-6f0c-4037-8d0e-b7e36a8a0c32" * ] * } */ ``` ## Assign a badge. (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { badges } from 'wix-members.v2'; import { elevate } from 'wix-auth'; /* Sample id value: 'd5786246-271d-40d1-bbe5-346244e89799' * * Sample memberIds value: * [ * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32' * ] */ export const myAssignBadgeFunction = webMethod(Permissions.Anyone, async (_id, memberIds) => { try { const elevatedAssignBadge = elevate(badges.assignBadge); const membersIdsWithBadge = await elevatedAssignBadge(_id, memberIds); console.log('MemberIds with assigned badge: ', membersIdsWithBadge); return membersIdsWithBadge; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "memberIds": [ * "7d368843-6f0c-4037-8d0e-b7e36a8a0c32" * ] * } */ ``` ---