Home Forums Front-end Issues Field Group frontend form with text area set as post title?


Field Group frontend form with text area set as post title?

  • Hi, I’m trying to set a text field to the post title for an ACF field group that’s being used as a frontend form to create new posts (to a custom post type) when users fill it out. The field group itself has a lot of conditional fields that show/hide depending on what’s selected (so it’s somewhat lengthy on the backend, just not on the frontend for users) which is why I’m trying to avoid just creating the field group in php manually (plus I’m bad at it). However I don’t see a way to set a user-entered text field to be saved as the new post’s title?

    For example in the field group I have the image upload field with the field name saved as _thumbnail_id and this saves the user uploaded image as the featured thumbnail for the post. Is there a simple way to replicate that for the post title?

    The form itself is in a custom page template specifically for this use case, so this is the code I have for making the form appear on that page:

    <div id="acf-form">
                        <?php acf_form(array(
                            'post_id'       => 'new_post',
                            'new_post'      => array(
                                'post_type'     => 'fancy_custom_post_type',
                                'post_status'   => 'Pending'
                            'submit_value'  => 'Submit new resource'
                        )); ?>

    Any help appreciated. I imagine there has to be some way to set a field code to save as the post title? I’m probably over complicating it! But most answers I’ve found are from 8+ years ago and involve registering the field group manually.

  • acf_form() has an argument that automatically add a standard WP post title field 'post_title' => true.

    If this will not work for you then you must create an acf/save_post action, as in this example.

  • Thank you! I apparently misread that documentation multiple times, first thinking it needed to go in the function for the field group (and not in the form on the template) and then putting it inside the new post array instead of the form array 😅.

    Managed to get it working though, thanks for pointing out the obvious!

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

You must be logged in to reply to this topic.