Formidable Shortcode

Below, you’ll find a detailed guide on how to add the Formidable 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 Formidable Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Formidable Plugin and the shortcodes it provides:

Plugin Icon
Formidable Forms – Contact Form, Survey, Quiz, Payment, Calculator Form & Custom Form Builder

"Formidable Forms is a versatile WordPress plugin. It simplifies creating contact forms, surveys, quizzes, payment forms, calculators, and custom forms. Transform your website's interaction with ease using the Formidable plugin."

★★★★☆ (1018) Active Installs: 300000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [formidable]

Formidable [formidable] Shortcode

The shortcode ‘formidable’ is designed to fetch and display a specific form on a webpage. It uses various parameters (id, key, title, description, etc.) to identify and customize the form. If the form is not found or not visible to the user, it returns a specific message. The ‘show_form’ function is called within this shortcode. It further refines the form’s visibility and appearance, ensuring that the form is not in draft mode and is accessible to the user. This shortcode is highly versatile, allowing for extensive customization and ensuring the correct form is displayed to the right audience.

Shortcode: [formidable]

Parameters

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

  • id – A unique identifier of the contact form.
  • key – A unique key associated with the contact form.
  • title – Controls the display of the form’s title. Set to ‘auto’ by default.
  • description – Controls the display of the form’s description. Set to ‘auto’ by default.
  • readonly – If set to true, the form fields will be read-only.
  • entry_id – Used to define a specific entry id for the form.
  • fields – An array of fields to be included in the form.
  • exclude_fields – An array of fields to be excluded from the form.
  • minimize – If set to true, the form will be minimized.

Examples and Usage

Basic example – A simple shortcode usage to display a form using its ID

[formidable id=1 /]

Advanced examples

Displaying a form by its key, with the title and description set to be shown automatically:

[formidable key="contact_form" title="auto" description="auto" /]

Displaying a form by its ID, with specific fields excluded:

[formidable id=1 exclude_fields="field1,field2" /]

Using the shortcode to display a contact form by referencing both ID and key. The form will first try to load by ID, but if not found, it will try to load by key. The ‘minimize’ attribute is set to true, meaning the form will be displayed in a minimized state:

[formidable id=1 key="contact_form" minimize=true /]

PHP Function Code

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

Shortcode PHP function:

public static function get_form_shortcode( $atts ) {
		global $frm_vars;
		if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
			$sc = '[formidable';
			$sc .= FrmAppHelper::array_to_html_params( $atts );
			return $sc . ']';
		}

		$shortcode_atts = shortcode_atts(
			array(
				'id'             => '',
				'key'            => '',
				'title'          => 'auto',
				'description'    => 'auto',
				'readonly'       => false,
				'entry_id'       => false,
				'fields'         => array(),
				'exclude_fields' => array(),
				'minimize'       => false,
			),
			$atts
		);
		do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );

		return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
	}

	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
		$form = self::maybe_get_form_by_id_or_key( $id, $key );

		if ( ! $form ) {
			return __( 'Please select a valid form', 'formidable' );
		}

		if ( 'auto' === $title ) {
			$title = ! empty( $form->options['show_title'] );
		}

		if ( 'auto' === $description ) {
			$description = ! empty( $form->options['show_description'] );
		}

		FrmAppController::maybe_update_styles();

		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
		FrmAppHelper::trigger_hook_load( 'form', $form );

		$form = apply_filters( 'frm_pre_display_form', $form );

		$frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );

		if ( self::is_viewable_draft_form( $form ) ) {
			// don't show a draft form on a page
			$form = __( 'Please select a valid form', 'formidable' );
		} elseif ( ! FrmForm::is_visible_to_user( $form ) ) {
			$form = do_shortcode( $frm_settings->login_msg );
		} else {
			do_action( 'frm_pre_get_form', $form );
			$form = self::get_form( $form, $title, $description, $atts );

			/**
			 * Use this shortcode to check for external shortcodes that may span
			 * across multiple fields in the customizable HTML
			 *
			 * @since 2.0.8
			 */
			$form = apply_filters( 'frm_filter_final_form', $form );
		}

		return $form;
	}

Conclusion

Now that you’ve learned how to embed the Formidable 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 *