Search.../

updateBadgesDisplayOrder( )

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. (dashboard page code)

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

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