This filter allows you to modify the $post_id before any custom field data is saved from the front end form (acf_form()). This filter is used in the tutorial Using acf_form to create a new post.

This filter is not required to create a new post due to the new_post argument added to acf_form() in v5.0.0


  • Added in v4.0.0


Name Type Description
post_id int The post ID to which all the $_POST data (values) will be saved to


This code could be used in the functions.php file, or on the page template which features the front end form (above the acf_form_head function)



function my_pre_save_post( $post_id ) {

    // check if this is to be a new post
    if( $post_id != 'new' ) {

        return $post_id;


    // Create a new post
    $post = array(
        'post_status'  => 'draft' ,
        'post_title'  => 'A title, maybe a $_POST variable' ,
        'post_type'  => 'post' ,

    // insert the post
    $post_id = wp_insert_post( $post ); 

    // return the new ID
    return $post_id;


add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );



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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.