Info about wp_die from codex: Kill WordPress execution and display HTML message with error message. A call to this function complements the die() PHP function. The difference is that HTML will be displayed to the user. It is recommended to use this function only when the execution should not continue any further.
I have code:
function myHook( $post_ID, $post )
{
wp_die('Error', 'Error', array( 'response' => 500, 'back_link' => true ));
}
add_action( 'save_post', 'myHook', 0, 2 );
Problem is that error page appears, but post is still inserted. Shouldn’t saving be interrupted by this hook? If I misunderstood description, how can I break execution so post will not be saved?
EDIT: I just found that save_post is called after instert to database not before. Does there exist any function called before insert that i can hook into?
Thanks in advance
Try filtering with
wp_insert_post_data
instead. It’s fromwp-includes/post.php
, line 2864.publish
is thepost_status
when you click the Publish or Update button. The four statuses I’ve found are: