Try filtering with wp_insert_post_data
instead. It’s from wp-includes/post.php
, line 2864.
add_filter( 'wp_insert_post_data', 'post_publish_filter_wpse_82356' );
function post_publish_filter_wpse_82356( $data ) {
// view/manipulate $data
if ('publish' == $data['post_status']) {
$msg = '<pre>' . var_export($data, true) . '</pre>';
wp_die($msg);
}
return $data;
}
publish
is the post_status
when you click the Publish or Update button. The four statuses I’ve found are:
- auto-draft – self-explanatory (also, status is set to this when you click Add New)
- draft – when you click Save Draft button
- inherit – when you click Preview button
- publish – when you click Publish or Update button