Search.../

onPostUpdated( )

A backend event that fires when a forum post is updated.

Description

The onPostUpdated() event handler runs when a an existing forum post in your site is updated. The received UpdatedPost object contains information about the post that was updated.

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

Syntax

function onPostUpdated(event: UpdatedPost): void

onPostUpdated Parameters

NAME
TYPE
DESCRIPTION
event
UpdatedPost

Information about the forum post that was updated.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

A backend event that occurs when a forum post of type DISCUSSION is updated

Copy Code
1// Place this code in a file named events.js
2// in the Backend section of your code files.
3
4export function wixForum_onPostUpdated(event) {
5 const postId = event.postId;
6 const posterId = event.post.ownerId;
7}
8
9/* Full post object:
10 * {
11 * "_id": "5f88058be9b6b100175b154f",
12 * "categoryId":"5f88058be9b6b100175b154d",
13 * "_ownerId":"32cf071a-ck2f-450f-ad74-5a25db0b1b6g",
14 * "title": "My Updated Post Title",
15 * "plainContent": "This is the updated text of my post.",
16 * "pinned": "true",
17 * "commentingDisabled": "false",
18 * "commentCount": 4,
19 * "likeCount": 13,
20 * "viewCount": 76,
21 * "_createdDate": "2020-10-26T07:18:20.297Z",
22 * "_editedDate": "2020-11-04T12:27:05.592Z",
23 * "_lastActivityDate": "2020-11-04T12:27:05.592Z",
24 * "slug": "my-updated-post-title",
25 * "pageUrl": "/forum/category-name/my-updated-post-title",
26 * "postType": "DISCUSSION"
27 * }
28 */
A backend event that occurs when a forum post of type QUESTION is updated

Copy Code
1// Place this code in a file named events.js
2// in the Backend section of your code files.
3
4export function wixForum_onPostUpdated(event) {
5 const postId = event.postId;
6 const postPageUrl = event.post.pageUrl;
7}
8
9/* 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 and vote for the best answer.",
16 * "bestAnswerCommentId": "5f88058be9b6b100175b154i",
17 * "pinned": "true",
18 * "commentingDisabled": "false",
19 * "commentCount": 9,
20 * "likeCount": 18,
21 * "viewCount": 64,
22 * "_createdDate": "2020-10-26T07:18:20.297Z",
23 * "_editedDate": "2020-11-04T12:27:05.592Z",
24 * "_lastActivityDate": "2020-11-04T12:27:05.592Z",
25 * "slug": "what-topics-should-we-discus",
26 * "pageUrl": "/forum/category-name/what-topics-should-we-discuss",
27 * "postType": "QUESTION"
28 * }
29 */