onCommentCreated( )


A backend event that fires when a new forum comment is created.

The onCommentCreated() event handler runs when a new forum comment is created in your site. The received CreatedComment object contains information about the new comment that was created.

Note: Backend events are not fired when previewing your site.

Method Declaration
Copy
function onCommentCreated(event: CreatedComment): void;
Method Parameters
eventCreatedCommentRequired

Information about the forum comment that was created.

A backend event that occurs when a new forum comment is created
JavaScript
// Place this code in a file named events.js // in the Backend section of your code files. export function wixForum_onCommentCreated(event) { const commentId = event.commentId; const commentText = event.comment.plainContent; } /* Full comment object: * { * "_id": "5f88058be9b6b100175b154c", * "postId":"5f88058be9b6b100175b154a", * "_ownerId":"32cf071a-ck2f-450f-ad74-5a25db0b1b6g", * "plainContent": "This is my comment text.", * "replyCount": 0, * "likeCount": 0, * "upvoteCount": 0, * "downvoteCount": 0, * "score": 0, * "_createdDate": "2020-10-26T07:18:20.297Z", * "_editedDate": null, * "_lastActivityDate": "2020-10-26T07:18:20.297Z", * "pageUrl": "/forum/main/comment/5f88058be9b6b100175b154c" * } */
Errors

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

Did this help?