Create a Front-End Form with ACF

Use acf_form() to build front-end forms for submitting or editing posts with ACF fields.

php field-types
|

Use acf_form() to build front-end forms for submitting or editing posts with ACF fields.

First, call acf_form_head() before any HTML output — typically in your template before get_header():

<?php
// At the very top of your page template (before get_header).
acf_form_head();
get_header();
?>

Create a form to submit a new post:

<?php
acf_form( [
    'post_id'       => 'new_post',
    'new_post'      => [
        'post_type'   => 'event',
        'post_status' => 'draft',
    ],
    'field_groups'   => [ 'group_event_details' ],
    'submit_value'   => 'Submit Event',
    'updated_message' => 'Event submitted successfully!',
    'return'         => home_url( '/thank-you/' ),
] );
?>

Create a form to edit an existing post:

<?php
acf_form( [
    'post_id'       => get_the_ID(),
    'field_groups'   => [ 'group_event_details' ],
    'submit_value'   => 'Update Event',
    'updated_message' => 'Event updated.',
] );
?>

Display only specific fields instead of a full field group:

<?php
acf_form( [
    'post_id' => get_the_ID(),
    'fields'  => [ 'event_name', 'event_date', 'location' ],
    'submit_value' => 'Save Changes',
] );
?>

Edit the current user’s profile fields:

<?php
if ( is_user_logged_in() ) {
    acf_form( [
        'post_id'     => 'user_' . get_current_user_id(),
        'field_groups' => [ 'group_user_profile' ],
        'submit_value' => 'Update Profile',
    ] );
}
?>

Note: acf_form() is an ACF PRO feature. The form includes CSRF protection via nonces automatically. Users must be logged in to submit forms unless you customise the permission handling.

Related Snippets

Stay Updated

Get ACF tips and new extensions in your inbox

No spam. Unsubscribe anytime.