onPostUpdated( )


An event that triggers when a post is updated.

The onPostUpdated() event handler runs when a post is updated. The received PostUpdated object contains information about the post that was updated.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
function wixBlog_onPostUpdated(event: PostUpdated): void;
Method Parameters
eventPostUpdated

Information about the post that was updated.

An event that occurs when a post is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixBlog_onPostUpdated(event) { const postId = event.metadata.entityId; const postUpdateDate = event.entity.lastPublishedDate; console.log("Post updated", event); } /* Full event object: * * { * "metadata":{ * "id":"8b00dc16-9404-4207-92ac-ac03a5ec528b", * "entityId":"f11052c1-84f1-456e-8583-82173da8509d", * "eventTime":"2022-06-16T14:49:55.712Z", * "triggeredByAnonymizeRequest":false * }, * "entity":{ * "_id":"f11052c1-84f1-456e-8583-82173da8509d", * "categoryIds":[], * "commentingEnabled":true, * "contactId":"33d02592-dd28-4eff-9b8e-4c3bb9c737dd", * "excerpt":"Updating a blog post.", * "featured":false, * "firstPublishedDate":"2022-06-16T14:42:19.087Z", * "hashtags":[], * "language":"en", * "lastPublishedDate":"2022-06-16T14:49:55.554Z", * "memberId":"33d02592-dd28-4eff-9b8e-4c3bb9c737dd", * "minutesToRead":1, * "pinned":false, * "preview": false, * "pricingPlanIds":[], * "relatedPostIds":[], * "richContent":{ * "nodes":[ * { * "type":"PARAGRAPH", * "_id":"foo", * "nodes":[ * { * "type":"TEXT", * "_id":"", * "nodes":[], * "textData":{ * "text":"Updating a blog post.", * "decorations":[] * } * } * ], * "paragraphData":{ * "textStyle":{ * "textAlignment":"AUTO" * }, * "indentation":0 * } * } * ], * "metadata":{ * "version":1, * "createdTimestamp":"2022-06-16T14:49:55.710Z", * "updatedTimestamp":"2022-06-16T14:49:55.710Z", * "_id":"253928e4-71bc-41d5-bcb6-35a604ea8229"}, * "documentStyle":{} * }, * } * "slug":"new-blog-post", * "tagIds":[], * "title":"Updated Blog Post", * "translationId": "", * "url":"http://https://tadasz7.wixsite.com/blog-velo-events/post/new-blog-post" * } * } */
Errors

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

Did this help?