rest_delete_<post_type>
Fires immediately after a single post is deleted or trashed via the REST API.
Description
They dynamic portion(s) of the hook name refer to the post type slug.
Parameters (3)
- 0. $post (object)
- The deleted or trashed post.
- 1. $response (WP_REST_Response)
- The response data.
- 2. $request (WP_REST_Request)
- The request sent to the API.
Usage
- To run the hook, copy the example below.
- // run the action
- do_action( 'rest_delete_{$post_type}', $post, $response, $request );
- The following example is for adding a hook callback.
- // define the rest_delete_<post_type> callback
- function action_rest_delete_post_type( $post, $response, $request ) {
- // make action magic happen here...
- };
- // add the action
- add_action( "rest_delete_{$post_type}", 'action_rest_delete_post_type', 10, 3 );
- To remove a hook callback, use the example below.
- // remove the action
- remove_action( "rest_delete_{$post_type}", 'action_rest_delete_post_type', 10, 3 );
Defined (1)
The action is defined in the following location(s).
- /wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- do_action( "rest_delete_{$this->post_type}", $post, $response, $request );