Wix Reviews events are triggered when certain events occur with reviews in your site's backend. 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 sender detail events.
Note: Backend events aren't triggered when previewing your site.
To add a Reviews event handler, add an events.js file to the Backend section of 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:
export function <wixAppName>_<eventName>(event) { }
For example, an event handler that handles the creation of a review looks like this:
export function wixReviews_onReviewCreated(event) {}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when moderation status is set to APPROVED.
function wixReviewsV1_onReviewPublished(event: ReviewPublishedEvent): void;
export function wixReviewsV1_onReviewPublished(event) {
const eventId = event.metadata.id;
const entityId = event.data.review._id;
}
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 review is created.
function wixReviews_onReviewCreated(event: ReviewCreated): void;
export function wixReviews_onReviewCreated(event) {
const eventId = event.metadata.id;
const entityId = event.entity._id;
}
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 review is deleted.
function wixReviews_onReviewDeleted(event: ReviewDeleted): void;
export function wixReviews_onReviewDeleted(event) {
const eventId = event.metadata.id;
const entityId = event.entity._id;
}
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 review's moderation status is changed.
function wixReviews_onReviewModerationStatusChanged(
event: ReviewModerationStatusChanged,
): void;
export function wixReviews_onReviewModerationStatusChanged(event) {
const eventId = event.metadata.id;
const entityId = event.data.review._id;
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.