Search...
onPostCreated( )
An event that is triggered when a post is created.
Description
The onPostCreated()
event handler runs when a post is created. The PostCreated
object contains information about the post that was created.
Note: Backend events don't work when previewing your site.
Syntax
function wixBlog_onPostCreated(event: PostCreated): void
onPostCreated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
PostCreated
Information about the post that was created.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event that occurs when a blog post is created
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixBlog_onPostCreated(event) {6 const postId = event.metadata.entityId;7 const memberId = event.entity.memberId;8 console.log('Post created', event);9}101112/* Full event object:13 *14 * {15 * "metadata":{16 * "id":"d1874d29-6525-4e69-8544-e065617d0c42",17 * "entityId":"f11052c1-84f1-456e-8583-82173da8509d",18 * "eventTime":"2022-06-16T14:42:18.271Z"19 * },20 * "entity":{21 * "_id":"f11052c1-84f1-456e-8583-82173da8509d",22 * "categoryIds":[],23 * "commentingEnabled":true,24 * "contactId":"33d02592-dd28-4eff-9b8e-4c3bb9c737dd",25 * "excerpt":"Creating a blog.",26 * "featured":false,27 * "firstPublishedDate":"2022-06-16T14:42:18.087Z",28 * "hashtags":[],29 * "language":"en",30 * "lastPublishedDate":"2022-06-16T14:42:18.087Z",31 * "memberId":"33d02592-dd28-4eff-9b8e-4c3bb9c737dd",32 * "minutesToRead":1,33 * "pinned": false,34 * "preview": false,35 * "pricingPlanIds":[],36 * "relatedPostIds":[],37 * "richContent":{38 * "nodes":[39 * {40 * "type":"PARAGRAPH",41 * "_id":"foo",42 * "nodes":[43 * {44 * "type":"TEXT",45 * "_id":"",46 * "nodes":[],47 * "textData":{48 * "text":"Creating a blog.",49 * "decorations":[]50 * }51 * }52 * ],53 * "paragraphData":{54 * "textStyle":{55 * "textAlignment":"AUTO"56 * },57 * "indentation":058 * }59 * }60 * ],61 * "metadata":{62 * "version":1,63 * "createdTimestamp":"2022-06-16T14:42:18.270Z",64 * "updatedTimestamp":"2022-06-16T14:42:18.270Z",65 * "_id":"253928e4-71bc-41d5-bcb6-35a604ea8229"66 * },67 * "documentStyle":{}68 * },69 * "slug":"new-blog-post",70 * "tagIds":[],71 * "title":"New Blog Post",72 * "translationId": "",73 * "url":"http://https://tadasz7.wixsite.com/blog-velo-events/post/new-blog-post"74 * }75 * }76*/