Search.../

onPostDeleted( )

An event that is triggered when a post is deleted.

Description

The onPostDeleted() event handler runs when a post is deleted. The received PostDeleted object contains event metadata.

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

Syntax

function wixBlog_onPostDeleted(event: PostDeleted): void

onPostDeleted Parameters

NAME
TYPE
DESCRIPTION
event
Optional
PostDeleted

Information about the post that was deleted.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event that occurs when a blog post is deleted

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3// Add the file if it doesn't exist.
4
5export function wixBlog_onPostDeleted(event) {
6 const deletedPostId = event.metadata.entityId;
7 console.log('Post deleted', event);
8}
9
10
11/* Full event object:
12 * {
13 * "metadata":{
14 * "id":"416ba1ea-b7a0-432d-9a65-a8b5b0b2208c",
15 * "entityId":"ecec1fb1-d21a-4bf8-9e01-c6e4f231ae67",
16 * "eventTime":"2022-06-16T14:21:40.065Z",
17 * "triggeredByAnonymizeRequest":false
18 * }
19 * }
20 */