> 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: updateBadge(_id: string, badge: UpdateBadge) # Method package: wixMembersV2 # Method menu location: wixMembersV2 --> badges --> updateBadge # Method Link: https://dev.wix.com/docs/velo/apis/wix-members-v2/badges/update-badge.md # Method Description: Updates a badge. The `updateBadge()` function returns a Promise that resolves to the updated badge. Only the properties passed in the `BadgeInfo` object will be updated. All other properties will remain the same. Because the badge `slug` is based on the badge `title`, if you change `title`, `slug` is updated accordingly. `badgeId` 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. ## Update existing badge. (dashboard page code) ```javascript import { badges } from 'wix-members.v2'; /* Sample _id value: '215be5d9-4b32-4861-9eb5-2152930dd0b4' * * Sample badge value: * { * backgroundColor: "#FED8B1", * description: "Contributed 5 posts this month", * icon: "https://static.wixstatic.com/shapes/132b9a3d51884000acaf705eeeb0e296.svg", * textColor: "#000000", * title: "Rising Star" * } */ export async function myUpdateBadgeFunction(_id, badge) { try { const updateBadge = await badges.updateBadge(_id, badge); console.log('Updated badge:', updateBadge); return updateBadge; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "_createdDate": "2024-01-18T10:27:14.878Z", * "_id": "215be5d9-4b32-4861-9eb5-2152930dd0b4", * "_updatedDate": "2024-01-18T14:50:36.174Z", * "backgroundColor": "#FED8B1", * "description": "Contributed 5 posts this month", * "icon": "https://static.wixstatic.com/shapes/132b9a3d51884000acaf705eeeb0e296.svg", * "permissionsEnabled": true, * "slug": "super-contributor", * "textColor": "#000000", * "title": "Rising Star" * } */ ``` ## Update existing 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: '215be5d9-4b32-4861-9eb5-2152930dd0b4' * * Sample badge value: * { * backgroundColor: "#FED8B1", * description: "Contributed 5 posts this month", * icon: "https://static.wixstatic.com/shapes/132b9a3d51884000acaf705eeeb0e296.svg", * textColor: "#000000", * title: "Rising Star" * } */ export const myUpdateBadgeFunction = webMethod(Permissions.Anyone, async (_id, badge) => { try { const elevatedUpdateBadge = elevate(badges.updateBadge); const updateBadge = await elevatedUpdateBadge(_id, badge); console.log('Updated badge:', updateBadge); return updateBadge; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "_createdDate": "2024-01-18T10:27:14.878Z", * "_id": "215be5d9-4b32-4861-9eb5-2152930dd0b4", * "_updatedDate": "2024-01-18T14:50:36.174Z", * "backgroundColor": "#FED8B1", * "description": "Contributed 5 posts this month", * "icon": "https://static.wixstatic.com/shapes/132b9a3d51884000acaf705eeeb0e296.svg", * "permissionsEnabled": true, * "slug": "super-contributor", * "textColor": "#000000", * "title": "Rising Star" * } */ ``` ---