Add validation and error handling when saving custom fields?

I have a function that defines a custom field on a post type. Say the field is “subhead”. When the post is saved, I want to do some validation on the input, and display an error message on the post edit screen if necessary. Something like: // Handle post updating function wpse_update_post_custom_values($post_id, $post) { // … Read more

what is correct way to hook when update post

i try to hook when post is updated but all hook i try never executed except updated_post_meta add_action(‘updated_post_meta’, ‘my_function’); function my_function($post_id) { echo ‘This is my post ID : ‘.$post_id; } I’ve tried this add_action(‘save_post’, ‘my_function’); but no id was echo out, or maybe this message already echo but never renders because of redirect header … Read more