Events are triggered in your site’s backend when certain changes occur to your site’s members. You can write event handlers that react to these events. Event handler functions receive data that correspond to the backend event that has occurred. Use event handlers to create custom responses to the events.
Note: Backend events don’t work when previewing your site.
To add a members event handler, add an events.js file to the Backend or your site if one does not already exist. All event handler functions for your site are defined in this file.
Event handler functions are defined using the following pattern:
For example, an event handler that handles the creation of a member looks like this:
Triggered when a member receives a badge.
function wixBadges_onBadgeAssigned(event: BadgeAssignedEvent): void;
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixBadges_onBadgeAssigned(event) {
const memberId = event.data.memberId;
console.log(`Badge assgigned to member ${memberId}`);
}
/* Full event object:
* {
* "data": {
* "memberId": "ff20c02e-3d13-4412-9529-d628aa0abc12"
* },
* "metadata": {
* "entityId": "348b66e1-fb48-4b2d-8a68-6c69e3ac967b",
* "eventTime": "2024-03-22T06:09:09.752905936Z",
* "id": "25bf06fe-c6bb-4254-a1d0-a98502a6a041",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when a badge is created.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when a badge is deleted.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when a member's badge is removed.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when a badge is updated.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a badge is created.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a badge is deleted.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a badge is updated.
This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.