rest_pre_insert_page filter-hookWP 4.7.0

Filters a post before it is inserted via the REST API.

This is one of the variants of the dynamic hook rest_pre_insert_(post_type)

Usage

add_filter( 'rest_pre_insert_page', 'wp_kama_rest_pre_insert_page_filter', 10, 2 );

/**
 * Function for `rest_pre_insert_page` filter-hook.
 * 
 * @param stdClass        $prepared_post An object representing a single post prepared for inserting or updating the database.
 * @param WP_REST_Request $request       Request object.
 *
 * @return stdClass
 */
function wp_kama_rest_pre_insert_page_filter( $prepared_post, $request ){

	// filter...
	return $prepared_post;
}
$prepared_post(stdClass)
An object representing a single post prepared for inserting or updating the database.
$request(WP_REST_Request)
Request object.

Changelog

Since 4.7.0 Introduced.

Where the hook is called

WP_REST_Posts_Controller::prepare_item_for_database()
rest_pre_insert_page
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1346
return apply_filters( "rest_pre_insert_{$this->post_type}", $prepared_post, $request );

Where the hook is used in WordPress

Usage not found.