Search...
onCommentCreated( )
A backend event that fires when a new forum comment is created.
Description
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.
Syntax
function onCommentCreated(event: CreatedComment): void
onCommentCreated Parameters
NAME
TYPE
DESCRIPTION
event
CreatedComment
Information about the forum comment that was created.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
A backend event that occurs when a new forum comment is created
Copy Code
1// Place this code in a file named events.js2// in the Backend section of your code files.34export function wixForum_onCommentCreated(event) {5 const commentId = event.commentId;6 const commentText = event.comment.plainContent;7}89/* Full comment object:10 * {11 * "_id": "5f88058be9b6b100175b154c",12 * "postId":"5f88058be9b6b100175b154a",13 * "_ownerId":"32cf071a-ck2f-450f-ad74-5a25db0b1b6g",14 * "plainContent": "This is my comment text.",15 * "replyCount": 0,16 * "likeCount": 0,17 * "upvoteCount": 0,18 * "downvoteCount": 0,19 * "score": 0,20 * "_createdDate": "2020-10-26T07:18:20.297Z",21 * "_editedDate": null,22 * "_lastActivityDate": "2020-10-26T07:18:20.297Z",23 * "pageUrl": "/forum/main/comment/5f88058be9b6b100175b154c"24 * }25 */