Filter hook 'wp_insert_post_data'

in WP Core File wp-includes/post.php at line 4811

View Source

wp_insert_post_data

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

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Filter
Line Number 4811

Hook Parameters

Type Name Description
array $data An array of slashed, sanitized, and processed post data.
array $postarr An array of sanitized (and slashed) but otherwise unmodified post data.
array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as originally passed to wp_insert_post().
bool $update Whether this is an existing post being updated.

Usage Examples

Basic Usage
<?php
// Hook into wp_insert_post_data
add_filter('wp_insert_post_data', 'my_custom_filter', 10, 4);

function my_custom_filter($data, $postarr, $unsanitized_postarr, $update) {
    // Your custom filtering logic here
    return $data;
}

Source Code Context

wp-includes/post.php:4811 - How this hook is used in WordPress core
<?php
4806  		 * @param array $postarr             An array of sanitized (and slashed) but otherwise unmodified post data.
4807  		 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as
4808  		 *                                   originally passed to wp_insert_post().
4809  		 * @param bool  $update              Whether this is an existing post being updated.
4810  		 */
4811  		$data = apply_filters( 'wp_insert_post_data', $data, $postarr, $unsanitized_postarr, $update );
4812  	}
4813  
4814  	$data  = wp_unslash( $data );
4815  	$where = array( 'ID' => $post_id );
4816  

PHP Documentation

<?php
/**
		 * Filters slashed post data just before it is inserted into the database.
		 *
		 * @since 2.7.0
		 * @since 5.4.1 The `$unsanitized_postarr` parameter was added.
		 * @since 6.0.0 The `$update` parameter was added.
		 *
		 * @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.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.