# Front-End Submission Form With ACF

> Adds an [acf_submit_form] shortcode that lets logged-in users submit a new post (saved as pending review) using your ACF field groups.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, forms, front-end
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-front-end-form/

## Code

```php
// Field group keys shown in the form, and the post type created.
$wpide_acf_form_groups = array( 'group_wpide_post_extras' );
$wpide_acf_form_type   = 'post';

add_action( 'template_redirect', function () {
    // acf_form_head() must run before any output to process submissions.
    if ( function_exists( 'acf_form_head' ) && is_user_logged_in() && is_singular() && has_shortcode( (string) get_post_field( 'post_content', get_queried_object_id() ), 'acf_submit_form' ) ) {
        acf_form_head();
    }
} );

add_shortcode( 'acf_submit_form', function () use ( $wpide_acf_form_groups, $wpide_acf_form_type ) {
    if ( ! function_exists( 'acf_form' ) ) {
        return '';
    }

    if ( ! is_user_logged_in() ) {
        return '<p>Please <a href="' . esc_url( wp_login_url( get_permalink() ) ) . '">log in</a> to submit.</p>';
    }

    ob_start();
    acf_form( array(
        'post_id'         => 'new_post',
        'new_post'        => array( 'post_type' => $wpide_acf_form_type, 'post_status' => 'pending' ),
        'post_title'      => true,
        'field_groups'    => $wpide_acf_form_groups,
        'submit_value'    => 'Submit for review',
        'updated_message' => 'Thank you! Your submission is waiting for review.',
    ) );

    return ob_get_clean();
} );
```

## Notes

Set the field group key(s) and post type. Submissions wait for review; guests see a login link.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Front-End Submission Form With ACF" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
