Search...
onPostUpdated( )
An event that triggers when a post is updated.
Description
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.
Syntax
function wixBlog_onPostUpdated(event: PostUpdated): void
onPostUpdated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
PostUpdated
Information about the post that was updated.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event that occurs when a post is updated
Copy Code
12// Place this code in the events.js file3// of your site's Backend section.4// Add the file if it doesn't exist.56export function wixBlog_onPostUpdated(event) {7 const postId = event.metadata.entityId;8 const postUpdateDate = event.entity.lastPublishedDate;9 console.log('Post updated', event);10}111213/* Full event object:14 *15 * {16 * "metadata":{17 * "id":"8b00dc16-9404-4207-92ac-ac03a5ec528b",18 * "entityId":"f11052c1-84f1-456e-8583-82173da8509d",19 * "eventTime":"2022-06-16T14:49:55.712Z",20 * "triggeredByAnonymizeRequest":false21 * },22 * "entity":{23 * "_id":"f11052c1-84f1-456e-8583-82173da8509d",24 * "categoryIds":[],25 * "commentingEnabled":true,26 * "contactId":"33d02592-dd28-4eff-9b8e-4c3bb9c737dd",27 * "excerpt":"Updating a blog post.",28 * "featured":false,29 * "firstPublishedDate":"2022-06-16T14:42:19.087Z",30 * "hashtags":[],31 * "language":"en",32 * "lastPublishedDate":"2022-06-16T14:49:55.554Z",33 * "memberId":"33d02592-dd28-4eff-9b8e-4c3bb9c737dd",34 * "minutesToRead":1,35 * "pinned":false,36 * "preview": false,37 * "pricingPlanIds":[],38 * "relatedPostIds":[],39 * "richContent":{40 * "nodes":[41 * {42 * "type":"PARAGRAPH",43 * "_id":"foo",44 * "nodes":[45 * {46 * "type":"TEXT",47 * "_id":"",48 * "nodes":[],49 * "textData":{50 * "text":"Updating a blog post.",51 * "decorations":[]52 * }53 * }54 * ],55 * "paragraphData":{56 * "textStyle":{57 * "textAlignment":"AUTO"58 * },59 * "indentation":060 * }61 * }62 * ],63 * "metadata":{64 * "version":1,65 * "createdTimestamp":"2022-06-16T14:49:55.710Z",66 * "updatedTimestamp":"2022-06-16T14:49:55.710Z",67 * "_id":"253928e4-71bc-41d5-bcb6-35a604ea8229"},68 * "documentStyle":{}69 * },70 * }71 * "slug":"new-blog-post",72 * "tagIds":[],73 * "title":"Updated Blog Post",74 * "translationId": "",75 * "url":"http://https://tadasz7.wixsite.com/blog-velo-events/post/new-blog-post"76 * }77 * }78*/