Dynamic Forms

Manage Advanced ACF Forms from the WordPress administration. This module is an enhanced version of the native ACF Form feature. While all native settings can used, Dynamic Forms adds many new settings and introduce “Actions” for a complete control over the form behavior.

Getting Started

Just like ACF Forms, first you need to create a Field Group that will contain the form’s fields. You can then create a new form from the ACF > Forms menu and assign that field group to the form. Once saved, the form will now map the Fields from the Field Group. This means those fields will be usable directly from the UI.

Out-of-the-box, the form will do nothing on submission. You’ll have to add one or multiple actions to define what you want to do with the form. Once correctly configured, you can display the form using acfe_form() function or [acfe_form] shortcode. Usage example:

<?php get_header(); ?>

    <!-- My Form -->
    <?php acfe_form('my-form'); ?>
<?php get_footer(); ?>

Template Tags

Templates Tags are UI helpers that retrieve & print dynamic content. There are different types of templates tags that retrieving different types of data.

Template TagOutput
{field:field_5e5c07b6dfae9}User field input
{field:my_field}User field input
{field:my_field:false}User field input (unformatted)
{fields}My text: User input

My textarea: User input

My date: 2020-03-01

{get_field:my_field}DB value (current post)
{get_field:my_field:current}DB value (current post)
{get_field:my_field:128}DB value (post:128)
{get_field:my_field:128:false}DB value (post:128 – unformatted)
{get_option:my_option}get_option('my_option') value
{get_option:my_option:key}get_option('my_option')['key'] value
{request:name}$_REQUEST['name'] value
{request:name:key}$_REQUEST['name']['key'] value
{query_var:name}get_query_var('name') value
{query_var:name:key}get_query_var('name')['key'] value
{current:post}Current post ID
{current:term}Current Term ID
{current:user}Current User ID
{current:author}Current Post Author ID
{current:form}Current Form ID

Forms Hooks

Dynamic Forms are bundled with general hooks allowing you to change the form settings, add validation rules and trigger a custom action on submission. Those hooks are tied to forms, and act independently from Actions.

Get Field

The get_field() function used in form & actions hooks allows to retrieve the fields input that are entered by the user during the form submission. In order to retrieve the field value from the database, you must set a valid post ID reference.

Template TagOutput
get_field('my_field')“my_field” Field input
get_field('my_field', 128)“my_field” DB value

Loading Hook

The acfe/form/load fitler is used to change the form settings, right before it is rendered on the page. Note that fields inputs cannot be retrieved using get_field() here, as the form hasn’t been submitted yet. Usage example:

 * Form Load
 * @array   $form     Form settings
 * @string  $post_id  Post ID (where the form is displayed)
filter('acfe/form/load',              $form, $post_id);
filter('acfe/form/load/form=my-form', $form, $post_id);
add_filter('acfe/form/load/form=my-form', 'my_form_load', 10, 2);
function my_form_load($form, $post_id){
    // Change form success message dynamically
    $form['updated_message'] = 'New success message!';
    // Change form redirection URL
    $form['return'] = '/thank-you';
    // Hide the form
    // return false;
    // Return
    return $form;

Validation Hook

The acfe/form/validation action is used to add rules during the ajax form validation process, before form submission.

Unlike the acf/validate_value hook which validate each fields values individually, acfe/form/validation will validate the whole form. It can be used to check one field against an another.

The acfe_add_validation_error() function should be used to return an error. It is possible to return a general error by omitting to reference a field’s name. Example: acfe_add_validation_error('', 'General error message'). Usage example:

 * Form Validation
 * @array   $form     Form settings
 * @string  $post_id  Post ID (where the form is displayed)
action('acfe/form/validation',              $form, $post_id);
action('acfe/form/validation/form=my-form', $form, $post_id);
add_action('acfe/form/validation/form=my-form', 'my_form_validation', 10, 2);
function my_form_validation($form, $post_id){
    // Get field input value
    $my_field = get_field('my_field');
    if($my_field === 'Company'){
        // Add validation error
        acfe_add_validation_error('my_field', 'The value Company is not allowed');

Submission Hook

The acfe/form/submit action is used to trigger a custom script on form submission, after its validation. Usage example:

 * Form Submit
 * @array   $form     Form settings
 * @string  $post_id  Post ID (where the form is displayed)
action('acfe/form/submit',              $form, $post_id);
action('acfe/form/submit/form=my-form', $form, $post_id);
add_action('acfe/form/submit/form=my-form', 'my_form_submit', 10, 2);
function my_form_submit($form, $post_id){
    // Get field input value
    $my_field = get_field('my_field');
    if($my_field === 'Company'){
        // Do something...

Forms Actions

Actions are pre-defined templates that trigger a specific behavior. There can be an unlimited number of Actions per form. While every Actions have unique features like create a post, a user or send an e-mail, they also have their own validation & submit hooks.

Form Actions also have their own specific hooks that allow you to change their behavior. Learn more about Actions:

Export/Import Forms

It is possible to export and import Forms in a Json file using the ACF > Tools menu or directly within the Dynamic Forms UI.

Disable The Module

This module is enabled by default. To disable it, you can use the following code:

add_action('acf/init', 'my_acfe_modules');
function my_acfe_modules(){

    // Disable Dynamic Forms
    acfe_update_setting('modules/dynamic_forms', false);
    // Or:
    acf_update_setting('acfe/modules/dynamic_forms', false);