Home Forums ACF PRO Front-end forms pro or no? Reply To: Front-end forms pro or no?

  • @james – Thanks. I got it to work late yesterday. In the end, I used the following code. The area where I had to do a little digging was getting the field_group property assigned correctly. After that I set the post_id to 'new' in both files and I’m set.

    Edit – changed the check on $post_id to 'new_post' to clear the form after each use.

    function pre_save_request_form($post_id) {
            // check if there's a new request based on post id
            // 'new' vs 'new_post'
            if ($post_id != 'new_post') {
                    return $post_id;
            if (is_admin()) {
            $post = array(
                    // check to see if a 'draft' status can be used.
                    'post_status' => 'draft',
                    // make the title a date w/ timestamp.
                    'post_title' => date("F j, Y, g:i a"),
                    'post_type' => 'request_form'
            // insert the posts
            $post_id = wp_insert_post($post);
            // return the new id
            return $post_id;
    add_filter('acf/pre_save_post', 'pre_save_request_form');
    Enable a front end ACF form which will generate a new post on submit.
     $fields = get_field_objects();
    // var_dump($fields);
    foreach ($fields as $field) {
        $fieldGroup = $field['field_group'];
        // var_dump($field, $fieldGroup);
    // var_dump($fieldGroup);
    $options = array(
        'post_id' => 'new_post',
         // field groups has to be an array...
         'field_groups' => array($fieldGroup),
         'submit_value' => 'Start a request',
         'return' => home_url('thank-you')