Action hook 'pre_post_update'

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

View Source

pre_post_update

Action Hook
Description
Fires immediately before an existing post is updated in the database.

Hook Information

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

Hook Parameters

Type Name Description
int $post_id Post ID.
array $data Array of unslashed post data.

Usage Examples

Basic Usage
<?php
// Hook into pre_post_update
add_action('pre_post_update', 'my_custom_function', 10, 2);

function my_custom_function($post_id, $data) {
    // Your custom code here
}

Source Code Context

wp-includes/post.php:4826 - How this hook is used in WordPress core
<?php
4821  		 * @since 2.5.0
4822  		 *
4823  		 * @param int   $post_id Post ID.
4824  		 * @param array $data    Array of unslashed post data.
4825  		 */
4826  		do_action( 'pre_post_update', $post_id, $data );
4827  
4828  		if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
4829  			if ( $wp_error ) {
4830  				if ( 'attachment' === $post_type ) {
4831  					$message = __( 'Could not update attachment in the database.' );

PHP Documentation

<?php
/**
		 * Fires immediately before an existing post is updated in the database.
		 *
		 * @since 2.5.0
		 *
		 * @param int   $post_id Post ID.
		 * @param array $data    Array of unslashed post data.
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.