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; ?>" />

    Happy ACF coding!

    // T