Search.../

updateBadgesDisplayOrder( )

Developer Preview

Updates badges' display order.

Description

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.

This function is not a universal function and runs only on the backend

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function updateBadgesDisplayOrder(badgeIds: Array<string>): Promise<UpdateBadgesDisplayOrderResponse>

updateBadgesDisplayOrder Parameters

NAME
TYPE
DESCRIPTION
badgeIds
Array<
string
>

Ordered badge IDs.

Returns

Return Type:

Promise<
UpdateBadgesDisplayOrderResponse
>
NAME
TYPE
DESCRIPTION
badges
Array<
Badge
>

Reordered badges list.

Was this helpful?

Updates badge display order.

Copy Code
1import { badges } from 'wix-members.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample badgeIds value:
5 * [
6 * '215be5d9-4b32-4861-9eb5-2152930dd0b4',
7 * 'aedd9a3d-1efa-45ce-85d6-df09a167e37e',
8 * 'e80fed60-687e-4b91-a24c-252c4b32227b'
9 * ]
10 */
11
12export async function myUpdateBadgesDisplayOrderFunction(badgeIds) {
13 try {
14 const elevatedUpdateBadgesDisplayOrder = elevate(badges.updateBadgesDisplayOrder);
15 const updatedBadgeDisplay = await elevatedUpdateBadgesDisplayOrder(badgeIds);
16
17 console.log('Updated badge display order: ', updatedBadgeDisplay);
18 return updatedBadgeDisplay;
19 } catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23
24}
25/* Promise resolves to:
26 * {
27 * "badges": [
28 * {
29 * "_createdDate": "2024-01-18T10:27:14.878Z",
30 * "_id": "215be5d9-4b32-4861-9eb5-2152930dd0b4",
31 * "_updatedDate": "2024-01-18T14:50:36.174Z",
32 * "backgroundColor": "#42A5F5",
33 * "description": "Outstanding Contributor Badge",
34 * "icon": "https://example.com/custom-badge-icon.svg",
35 * "permissionsEnabled": true,
36 * "slug": "super-contributor",
37 * "textColor": "#FFFF00",
38 * "title": "Super Contributor"
39 * },
40 * {
41 * "_createdDate": "2024-01-18T13:53:11.659Z",
42 * "_id": "aedd9a3d-1efa-45ce-85d6-df09a167e37e",
43 * "_updatedDate": "2024-01-18T13:53:11.659Z",
44 * "backgroundColor": "#796EFF",
45 * "description": "Completed challenging tasks and achieved milestones.",
46 * "icon": "https://static.wixstatic.com/shapes/11062b_30b982c4ceb141d884fa15ecfb07d26c.svg",
47 * "permissionsEnabled": false,
48 * "slug": "achievement-unlocked",
49 * "textColor": "#FFFFFF",
50 * "title": "Achievement Unlocked"
51 * },
52 * {
53 * "_createdDate": "2024-01-18T13:53:37.067Z",
54 * "_id": "e80fed60-687e-4b91-a24c-252c4b32227b",
55 * "_updatedDate": "2024-01-18T13:53:37.067Z",
56 * "backgroundColor": "#FF5C79",
57 * "description": "Recognized for outstanding community contributions and leadership.",
58 * "icon": "https://static.wixstatic.com/shapes/cb523e8b3f9b4908b85a4a1c577af32b.svg",
59 * "permissionsEnabled": false,
60 * "slug": "community-hero",
61 * "textColor": "#FFFFFF",
62 * "title": "Community Hero"
63 * }
64 * ]
65 * }
66 */