Search.../

onBadgeCreated( )

Developer Preview

Triggered when a badge is created.

Syntax

function wixBadges_onBadgeCreated(event: BadgeCreated): void

onBadgeCreated Parameters

NAME
TYPE
DESCRIPTION
event
Optional
BadgeCreated

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event that occurs when a badge is created

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3// Add the file if it doesn't exist.
4
5export function wixBadges_onBadgeCreated(event){
6 const eventTime = event.metadata.eventTime;
7 const badgeID = event.entity._id;
8
9 console.log(`Badge ${badgeID} has been created at ${eventTime}`);
10}
11
12/* Full event object:
13* {
14* "entity": {
15* "_createdDate": "2024-03-29T09:00:20.395Z",
16* "_id": "3e536ad8-486e-45d8-9c0a-eab0cce4f98c",
17* "_updatedDate": "2024-03-29T09:00:20.395Z",
18* "backgroundColor": "#FA8704",
19* "icon": "https://static.wixstatic.com/shapes/cb523e8b3f9b4908b85a4a1c577af32b.svg",
20* "permissionsEnabled": false,
21* "slug": "super-contributer",
22* "textColor": "#FFFFFF",
23* "title": "Super Contributer"
24* },
25* "metadata": {
26* "entityId": "3e536ad8-486e-45d8-9c0a-eab0cce4f98c",
27* "eventTime": "2024-03-29T09:00:20.500072301Z",
28* "id": "b34080a9-798f-4dce-84cd-53a313bcff24",
29* "triggeredByAnonymizeRequest": false
30* }
31* }
32*/