Search...
onPostCreated( )
A backend event that fires when a new forum post is created.
Description
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.
Syntax
function onPostCreated(event: CreatedPost): void
onPostCreated Parameters
NAME
TYPE
DESCRIPTION
event
CreatedPost
Information about the forum post 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 post 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_onPostCreated(event) {5 const postId = event.postId;6 const postPageUrl = event.post.pageUrl;7}89/* Full post object:10 * {11 * "_id": "5f88058be9b6b100175b154c",12 * "categoryId":"5f88058be9b6b100175b154a",13 * "_ownerId":"32cf071a-ck2f-450f-ad74-5a25db0b1b6g",14 * "title": "What topics should we discuss?",15 * "plainContent": "Let us know what you think in the comments below.",16 * "pinned": "false",17 * "commentingDisabled": "false",18 * "commentCount": 0,19 * "likeCount": 0,20 * "viewCount": 0,21 * "_createdDate": "2020-10-26T07:18:20.297Z",22 * "_editedDate": null,23 * "_lastActivityDate": "2020-10-26T07:18:20.297Z",24 * "slug": "what-topics-should-we-discus",25 * "pageUrl": "/forum/category-name/what-topics-should-we-discuss",26 * "postType": "QUESTION"27 * }28 */