Updates badges' display order.
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
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateBadgesDisplayOrder(
badgeIds: Array<string>,
): Promise<UpdateBadgesDisplayOrderResponse>;
Ordered badge IDs.
import { badges } from "wix-members.v2";
/* Sample badgeIds value:
* [
* '215be5d9-4b32-4861-9eb5-2152930dd0b4',
* 'aedd9a3d-1efa-45ce-85d6-df09a167e37e',
* 'e80fed60-687e-4b91-a24c-252c4b32227b'
* ]
*/
export async function myUpdateBadgesDisplayOrderFunction(badgeIds) {
try {
const updatedBadgeDisplay = await badges.updateBadgesDisplayOrder(badgeIds);
console.log("Updated badge display order: ", updatedBadgeDisplay);
return updatedBadgeDisplay;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "badges": [
* {
* "_createdDate": "2024-01-18T10:27:14.878Z",
* "_id": "215be5d9-4b32-4861-9eb5-2152930dd0b4",
* "_updatedDate": "2024-01-18T14:50:36.174Z",
* "backgroundColor": "#42A5F5",
* "description": "Outstanding Contributor Badge",
* "icon": "https://example.com/custom-badge-icon.svg",
* "permissionsEnabled": true,
* "slug": "super-contributor",
* "textColor": "#FFFF00",
* "title": "Super Contributor"
* },
* {
* "_createdDate": "2024-01-18T13:53:11.659Z",
* "_id": "aedd9a3d-1efa-45ce-85d6-df09a167e37e",
* "_updatedDate": "2024-01-18T13:53:11.659Z",
* "backgroundColor": "#796EFF",
* "description": "Completed challenging tasks and achieved milestones.",
* "icon": "https://static.wixstatic.com/shapes/11062b_30b982c4ceb141d884fa15ecfb07d26c.svg",
* "permissionsEnabled": false,
* "slug": "achievement-unlocked",
* "textColor": "#FFFFFF",
* "title": "Achievement Unlocked"
* },
* {
* "_createdDate": "2024-01-18T13:53:37.067Z",
* "_id": "e80fed60-687e-4b91-a24c-252c4b32227b",
* "_updatedDate": "2024-01-18T13:53:37.067Z",
* "backgroundColor": "#FF5C79",
* "description": "Recognized for outstanding community contributions and leadership.",
* "icon": "https://static.wixstatic.com/shapes/cb523e8b3f9b4908b85a4a1c577af32b.svg",
* "permissionsEnabled": false,
* "slug": "community-hero",
* "textColor": "#FFFFFF",
* "title": "Community Hero"
* }
* ]
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.