Wordpress Hook Pre Post Update

I am writing a wordpress plugin. I would like to set the publication status for publication if the status of the message is in the future.

I know one hook that should be used, which is pre_post_update.

However, where is the array of message-related details stored so that I can change post_status?

thanks for the help

+5
source share
1 answer

The function calling the pre_post_update hook appears on line 1525 of wp-includes / posts.php for me:

do_action( 'pre_post_update', $post_ID );

As you can see, it passes the identifier of the message updated when it is executed. To get a message from there, you simply call get_post(), for example:

function do_something_with_a_post($post_id, $post_data) {
     // now do something with $post_data
}
add_action('pre_post_update', 'do_something_with_a_post', 10, 2);

$post , , .

+10

All Articles