Getting started

In order to use shortcode you have to register a form, either in the “ACF > Forms” admin menu, or using a PHP code (see documentation).

Render Form

You can use the [acfe_form] shortcode in order to display the form in the WordPress Editor.

Render with form name

[acfe_form name="my-form"]

Render with form id

[acfe_form ID="120"]

Override Settings

It is possible to override form settings directly from the shortcode, to some extend. To do so you can refer to the Settings Cheatsheet, and find the argument you would like to override.

For example, in the following form:

acfe_form(array(
    'name'  => 'my-form',
    'attributes' => array(
        'submit' => array(
            'value' => 'Submit Form',
        ),
    ),
    'success' => array(
        'message' => 'Form has been submitted',
    )
));

The path to attributes > submit > value is:

attributes_submit_value="Submit Form"

The path to success > message is:

success_message="Form has been submitted"

So in this example, to override the submit button and the success message, the shortcode would be:

[acfe_form name="my-form" attributes_submit_value="Submit" success_message="Success!"]

Pass Custom Data

To pass custom data, simply add the custom key within the shortcode.

[acfe_form name="my-form" my_key="12"]

If the data is dynamic and must be set in PHP, then you can use the acfe/form/load_form filter. See documentation.

Usage example:

functions.php
add_filter('acfe/form/load_form/form=my-form', 'my_form_settings');
function my_form_settings($form){
    
    // add custom data
    $form['my_key'] = 12;
    
    // return
    return $form;
    
}

These custom data can then be retrieved in the Form UI using the {form:my_key} Template Tag. They are also available in any front-end forms hooks. Usage example:

functions.php
// form submission
add_action('acfe/form/submit_form/form=my-form', 'my_form_submit');
function my_form_submit($form){
    
    // retrieve custom data
    $my_key = $form['my_key'];

    // ...
    
}

Conditional Render

In order to conditionally display a form using the [acfe_form] shortcode, the acfe/form/load_form filter should be used. See documentation.

In this example, the form will be hidden if the user is not logged in:

functions.php
add_filter('acfe/form/load_form/form=my-form', 'my_form_load');
function my_form_load($form){
    
    // check if user is logged in
    if(!is_user_logged_in()){
        return false; // hide form
    }
    
    // display form
    return $form;
    
}

FREEShortcode Placeholder

The Shortcode display a placeholder within the WordPress Editor.

Field Group

PROShortcode Preview

It is possible to display a form preview directly within the WordPress editor using the Shortcode Preview setting.

Field Group

The Shortcode Preview setting is disabled by default. It can be enabled and disabled in the Settings UIPRO, or with the following code:

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

    // Enable Shortcode Preview for all Forms
    acf_update_setting('acfe/modules/forms/shortcode_preview', true);

    // Enable Shortcode Preview for all Forms
    acf_update_setting('acfe/modules/forms/shortcode_preview', array());

    // Enable Shortcode Preview for specific Forms
    acf_update_setting('acfe/modules/forms/shortcode_preview', array('my-form'));
    
}