Home › Forums › Feature Requests › Get post_id in validate_save_post › Reply To: Get post_id in validate_save_post
David,
For the acf/validate_save_post
action this can easily be done, without “hacking”, using the built in edit_form_after_title
action and add a hidden input field with the acf[post_id]
name.
The AJAX post on the post edit screen will serialize all acf named inputs, so in this way, you can easily use the post_id in one of your own acf/validate_save_post
hooks. 🙂
// acf/validate_save_post
add_action( 'edit_form_after_title', 'devplus_edit_form_after_title' );
function devplus_edit_form_after_title(){
global $post;
if( $post && isset( $post->ID ) ){
?>
<input type="hidden" name="acf[post_id]" value="<?php echo $post->ID; ?>" />
<?php
}
}
Happy ACF coding!
// T
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.