wp_insert_post_data filter-hookWP 2.7.0

Filters slashed post data just before it is inserted into the database.

Usage

add_filter( 'wp_insert_post_data', 'wp_kama_insert_post_data_filter', 10, 4 );

/**
 * Function for `wp_insert_post_data` filter-hook.
 * 
 * @param array $data                An array of slashed, sanitized, and processed post data.
 * @param array $postarr             An array of sanitized (and slashed) but otherwise unmodified post data.
 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as originally passed to wp_insert_post().
 * @param bool  $update              Whether this is an existing post being updated.
 *
 * @return array
 */
function wp_kama_insert_post_data_filter( $data, $postarr, $unsanitized_postarr, $update ){

	// filter...
	return $data;
}
$data(array)
An array of slashed, sanitized, and processed post data.
$postarr(array)
An array of sanitized (and slashed) but otherwise unmodified post data.
$unsanitized_postarr(array)
An array of slashed yet unsanitized and unprocessed post data as originally passed to wp_insert_post().
$update(true|false)
Whether this is an existing post being updated.

Changelog

Since 2.7.0 Introduced.
Since 5.4.1 The $unsanitized_postarr parameter was added.
Since 6.0.0 The $update parameter was added.

Where the hook is called

wp_insert_post()
wp_insert_post_data
wp-includes/post.php 4461
$data = apply_filters( 'wp_insert_post_data', $data, $postarr, $unsanitized_postarr, $update );

Where the hook is used in WordPress

wp-admin/includes/ms-admin-filters.php 26
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
wp-includes/class-wp-customize-manager.php 2954
add_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5, 3 );
wp-includes/class-wp-customize-manager.php 2985
remove_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5 );
wp-includes/default-filters.php 92
add_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data', 10, 2 );