onPostCreated( )


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

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

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

Method Declaration
Copy
function onPostCreated(event: CreatedPost): void;
Method Parameters
eventCreatedPostRequired

Information about the forum post that was created.

A backend event that occurs when a new forum post is created
JavaScript
// Place this code in a file named events.js // in the Backend section of your code files. export function wixForum_onPostCreated(event) { const postId = event.postId; const postPageUrl = event.post.pageUrl; } /* Full post object: * { * "_id": "5f88058be9b6b100175b154c", * "categoryId":"5f88058be9b6b100175b154a", * "_ownerId":"32cf071a-ck2f-450f-ad74-5a25db0b1b6g", * "title": "What topics should we discuss?", * "plainContent": "Let us know what you think in the comments below.", * "pinned": "false", * "commentingDisabled": "false", * "commentCount": 0, * "likeCount": 0, * "viewCount": 0, * "_createdDate": "2020-10-26T07:18:20.297Z", * "_editedDate": null, * "_lastActivityDate": "2020-10-26T07:18:20.297Z", * "slug": "what-topics-should-we-discus", * "pageUrl": "/forum/category-name/what-topics-should-we-discuss", * "postType": "QUESTION" * } */
Errors

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

Did this help?