Reputation: 1020
I am using WordPress hook as below
function modify_post_title( $data , $postarr )
{
$error = 0;
if(SomeVlidation == false) {
$error = 1;
}
return $error;
}
add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 2 );
as i made validation some conditions in my hook now what i want is that wp_insert_post_data
should not execute if my hook (modify_post_title) return $error = 1;
Upvotes: 1
Views: 54
Reputation: 14913
No, you cannot halt hook execution because action hooks don't check for return values from the callback function. The only option is to use wp_die
or exit
function modify_post_title( $data , $postarr )
{
$error = 0;
if(SomeVlidation == false) {
$error = 1;
wp_die("<p>Ok we are terminating here!!</p>");
}
return $error;
}
add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 2 );
Upvotes: 1