Introduction

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.

Working with Reviews Event Handlers

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:

Copy
export function <wixAppName>_<eventName>(event) { }

For example, an event handler that handles the creation of a review looks like this:

Copy
export function wixReviews_onReviewCreated(event) {}
Did this help?

onReviewPublished( )


Developer Preview

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.

Method Declaration
Copy
function wixReviewsV1_onReviewPublished(event: ReviewPublishedEvent): void;
Method Parameters
eventReviewPublishedEvent
onReviewPublished example
JavaScript
export function wixReviewsV1_onReviewPublished(event) { const eventId = event.metadata.id; const entityId = event.data.review._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onReviewCreated( )


Developer Preview

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.

Method Declaration
Copy
function wixReviews_onReviewCreated(event: ReviewCreated): void;
Method Parameters
eventReviewCreated
onReviewCreated example
JavaScript
export function wixReviews_onReviewCreated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onReviewDeleted( )


Developer Preview

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.

Method Declaration
Copy
function wixReviews_onReviewDeleted(event: ReviewDeleted): void;
Method Parameters
eventReviewDeleted
onReviewDeleted example
JavaScript
export function wixReviews_onReviewDeleted(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onReviewModerationStatusChanged( )


Developer Preview

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.

Method Declaration
Copy
function wixReviews_onReviewModerationStatusChanged(
  event: ReviewModerationStatusChanged,
): void;
Method Parameters
eventReviewModerationStatusChanged
onReviewModerationStatusChanged example
JavaScript
export function wixReviews_onReviewModerationStatusChanged(event) { const eventId = event.metadata.id; const entityId = event.data.review._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?