Home Forums Front-end Issues Front End Form Values Staying Filled


Front End Form Values Staying Filled

  • Hello,

    I have an ACF Form which is setup to post a new CPT as a draft once it is submitted and this currently works. However, if I return the the same page where my form was, all of the fields are still filled will the info I last filled out.

    For Example: I fill out the form with the title field filled out as “Test”, a new post is then created (in the admin, set to draft status) with the Title of “Test”. I return to my form to submit another post, but the form’s title field still has the Title of “Test” filled out.

    Is there any way to allow the front end form to be continually used to post new posts, instead of just updating the one?

    I’m displaying the form like this in page.php:

    $args = array(
    	'post_id' => 'new',
    	'field_groups' => array( 4137 )
    acf_form( $args );

    I’m creating the form like this in functions.php:

    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'  => 'Test' ,
            'post_type'  => 'resource_link' ,
        // insert the post
        $post_id = wp_insert_post( $post );
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
        // return the new ID
        return $post_id;
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
  • Hi @graphix

    Can you check your wp_options table for any rows where the option_name starts with ‘new_’ or ‘options_new_’.

    It is possible that during testing, your code saved it’s values with a post_id of ‘new’ and now your post is loading from ‘new’.

    If the rows exist in the DB. Please remove them, and your form should clear out.


  • Hi Elliot,

    That did it. I have two rows in my wp_options table (as I was testing with two fields). I deleted both rows and my form now submits correctly!

    Also, I’m not sure if I should start a new topic or not, but is there a way to change the post_title to pull the value from a field that has been setup? I tried this, but it did not work:

    'post_title' => $_POST["fields"]['page_title']

    Where page_title is the name of the field I setup in ACF.

    Thanks very much,


  • Nevermind I figured it out,

    I looked at the name of the field in the front end and added it to my code like this and my Custom Post Types now have their custom title:

    'post_title' => $_POST["fields"]['field_52b2ffdfdcad1']


  • Hello,

    I am also facing same issue. My Frontend form is prefilled with previous entries all the time

    I have created Registration Form in Backend with ACF. See attached screenshot.

    Now with using acf_form() function i am showing that Registration Form in Front-end.

    Issue 1 :
    Any user Register itself, then my Registration Form prefilled automatically with previous entries. I know that it comes from wp_options table.
    After i delete those entries from wp_options table then it is not showing previous entires. So my question is that do we have to clear all such entries each and everytime when new user create their account.
    Please find attached screenshot.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Front End Form Values Staying Filled’ is closed to new replies.