If custom field has bad value, cease saving post and display error
-
Hi!
I have now this:
add_action('save_post','save_details'); function save_details(){ global $post; if($post->post_type == "booking") { update_post_meta($post->ID,'numberSeats', "" . intval( $_POST['numberSeats'] ) ); } }
And I want it to be something like:
add_action('save_post','save_details'); function save_details(){ global $post; if($post->post_type == "booking") { if( !check_if_good_value($_POST['numberSeats']) ){ /* DO NOT SAVE THE POST AND RETURN THE USER TO THE EDIT SCREEN WITH AN ERROR MESSAGE*/ } update_post_meta($post->ID,'numberSeats', "" . intval( $_POST['numberSeats'] ) ); } }
What sould I do to display an error message in this case instead of saving the post? Cann I display the already entered data as well?
- The topic ‘If custom field has bad value, cease saving post and display error’ is closed to new replies.