Advanced Forms for ACF Shortcode

Below, you’ll find a detailed guide on how to add the Advanced Forms for ACF Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Advanced Forms for ACF Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Advanced Forms for ACF Plugin and the shortcodes it provides:

Plugin Icon
Advanced Forms for ACF

"Advanced Forms for ACF is a WordPress plugin designed to simplify your work by creating versatile, customizable forms. Its user-friendly interface makes form building a breeze."

★★★★★ (41) Active Installs: 3000+ Tested with: 6.2.3 PHP Version: 7.0
Included Shortcodes:
  • [advanced_form]

Advanced Forms for ACF [advanced_form] Shortcode

The ‘advanced_form’ shortcode is used to render a specific form on your WordPress site. It accepts a ‘form’ attribute that identifies the form to be displayed. The form’s ID or key is used as the identifier. The shortcode then calls the ‘render’ function to display the form, and the output is returned.

Shortcode: [advanced_form]

Parameters

Here is a list of all possible advanced_form shortcode parameters and attributes:

  • form – Specifies the unique key or ID of the form to be displayed
  • atts – Holds additional attributes to customize the form display

Examples and Usage

Basic example – Utilizes the shortcode to display a specific form by referencing its ID or key.

[advanced_form form=1 /]

Advanced examples

Example 1 – Uses the shortcode to display a form by referencing its ID or key, while also passing additional attributes. These attributes can be used to further customize the form’s behavior and appearance.

[advanced_form form=1 att1=value1 att2=value2 /]

Example 2 – Utilizes the shortcode to display a contact form by referencing both ID and title. The form will first try to load by ID, but if not found, it will try to load by title. This is useful in cases where form IDs may change due to migration or other factors.

[advanced_form form="Contact Us" /]

Example 3 – Uses the shortcode to display a form by referencing its ID, while also passing an array of attributes. This allows for more complex customizations and can be particularly useful when working with forms that have a large number of fields.

[advanced_form form=1 atts="array('att1' => 'value1', 'att2' => 'value2')" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [advanced_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'advanced_form', array( $this, 'form_shortcode' ) );

Shortcode PHP function:

                    function form_shortcode( $atts ) {
		if ( isset( $atts['form'] ) ) {

			$form_id_or_key = $atts['form'];
			unset( $atts['form'] );

			ob_start();

			$this->render( $form_id_or_key, $atts );

			$output = ob_get_clean();

			return $output;
		}
	}
                    

Code file location:

advanced-forms/advanced-forms/core/forms/forms-rendering.php

Conclusion

Now that you’ve learned how to embed the Advanced Forms for ACF Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *