I want to add custom validation to post(custom post type) before it save into the WordPress. I am using the Rest API to insert the post to custom post type. What I need is the fields which I created using ACF(Advance Custom Fields) should be validated before it actually save into the WordPress Backend. I tried to find the hook action for before save but no luck so far. Quick help will be appreciate.
I want to add custom validation to post(custom post type) before it save into the WordPress. I am using the Rest API to insert the post to custom post type. What I need is the fields which I created using ACF(Advance Custom Fields) should be validated before it actually save into the WordPress Backend. I tried to find the hook action for before save but no luck so far. Quick help will be appreciate.
By searching a lot to API documentation, I found the solution to my problem finally:
function my_rest_prepare_post( $prepared_post, $request ) {
...
}
add_filter( 'rest_pre_insert_posttype', 'my_rest_prepare_post', 10, 3 );