MW WP Form Shortcodes

Below, you’ll find a detailed guide on how to add the MW WP Form Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the MW WP Form Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the MW WP Form Plugin and the shortcodes it provides:

Plugin Icon
MW WP Form

"MW WP Form is a flexible and user-friendly WordPress plugin. It allows you to create custom forms for your site, enhancing user interaction and data collection."

★★★★✩ (22) Active Installs: 200000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [mwform_value]
  • [mw_wp_form_confirm_page]
  • [mwform_formkey]
  • [mwform]
  • [mwform_complete_message]

MW WP Form [mwform_value] Shortcode

The MW WP Form shortcode is a powerful tool that allows for dynamic input on your WordPress pages. It uses the ‘_input_page’ function to generate the content. This shortcode checks if a ‘value’ exists in the defaults array and if the ‘name’ attribute is set. If the ‘value’ attribute isn’t set, it applies a filter to assign a default value. It then merges the existing attributes with the defaults and returns the input page.

Shortcode: [mwform_value]

Parameters

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

  • atts – The attributes you want to assign to the form
  • element_content – The content of the form’s elements
  • value – Default value for the form field
  • name – Name of the form field

Examples and Usage

Basic example – An instance of the mw-wp-form plugin shortcode is used to call the ‘_input_page’ function. In this basic example, the ‘name’ attribute is specified, and the ‘value’ attribute is omitted, allowing the function to assign a default value.

[mwform form_key="your_form_key" name="your_field_name"]

Advanced examples

Here, the mw-wp-form plugin shortcode is used with both ‘name’ and ‘value’ attributes specified. This will override the default ‘value’ that would otherwise be assigned by the function.

[mwform form_key="your_form_key" name="your_field_name" value="your_value"]

In this advanced example, the mw-wp-form plugin shortcode is used with multiple ‘name’ and ‘value’ pairs. This allows for the creation of more complex forms with multiple fields.

[mwform form_key="your_form_key" name1="your_field_name1" value1="your_value1" name2="your_field_name2" value2="your_value2"]

PHP Function Code

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

Shortcode line:

add_shortcode( $this->shortcode_name, array( $this, '_input_page' ) );

Shortcode PHP function:

function _input_page( $atts, $element_content = null ) {
		$this->element_content = $element_content;

		if ( array_key_exists( 'value', $this->defaults ) && isset( $atts['name'] ) && ! isset( $atts['value'] ) ) {
			$atts['value'] = apply_filters(
				'mwform_value_' . $this->form_key,
				$this->defaults['value'],
				$atts['name']
			);
		}
		$this->atts = shortcode_atts( $this->defaults, $atts );

		return $this->input_page();
	}

Code file location:

mw-wp-form/mw-wp-form/classes/abstract/class.form-field.php

MW WP Form [mw_wp_form_confirm_page] Shortcode

The MW-WP-Form shortcode is designed to create a confirmation page. It takes attributes and content, then returns the confirmation page.

Shortcode: [mw_wp_form_confirm_page]

Examples and Usage

Basic example – A simple usage of the shortcode to display a confirmation page. This shortcode doesn’t require any parameters or attributes, just use it as is to display the confirmation page.

[confirm_page /]

PHP Function Code

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

Shortcode line:

add_shortcode( $this->shortcode_name, array( $this, '_confirm_page' ) );

Shortcode PHP function:

function _confirm_page( $atts, $element_content = null ) {
		$this->element_content = $element_content;
		$this->atts            = shortcode_atts( $this->defaults, $atts );

		return $this->confirm_page();
	}

Code file location:

mw-wp-form/mw-wp-form/classes/abstract/class.form-field.php

MW WP Form [mwform_formkey] Shortcode

The MW WP Form shortcode, ‘mwform_formkey’, is used to initialize a form on a WordPress site. It takes attributes as parameters to customize the form. The related PHP function ‘_mwform_formkey’ triggers the execution of this shortcode. It creates a new instance of the ‘MW_WP_Form_Exec_Shortcode’ class and initializes it with the given attributes.

Shortcode: [mwform_formkey]

Examples and Usage

Basic example – A simple shortcode usage to execute the ‘mwform_formkey’ function with a single attribute. This attribute, ‘formkey’, is the unique identifier for the form you want to display.

[mwform_formkey formkey="contact_form"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'mwform_formkey', array( $this, '_mwform_formkey' ) );

Shortcode PHP function:

function _mwform_formkey( $attributes ) {
		$Exec_Shortcode = new MW_WP_Form_Exec_Shortcode();
		return $Exec_Shortcode->initialize( $attributes );
	}

Code file location:

mw-wp-form/mw-wp-form/classes/controllers/class.main.php

MW WP Form [mwform] Shortcode

The MW WP Form shortcode is a powerful tool that generates a form on your WordPress site. It adapts to different views (‘input’, ‘confirm’) and handles file uploads.

Shortcode: [mwform]

Examples and Usage

Basic example – In the basic usage of the mwform shortcode, you can simply call the shortcode with no parameters. This will display the form with its default settings.

[mwform]

PHP Function Code

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

Shortcode line:

add_shortcode( 'mwform', array( $this, '_mwform' ) );

Shortcode PHP function:

function _mwform( $attributes, $content = '' ) {
		$Form = new MW_WP_Form_Form();

		if ( in_array( $this->view_flg, array( 'input', 'confirm' ), true ) ) {
			$content            = $this->_get_the_content( $content );
			$upload_file_keys   = $this->Data->get_post_value_by_key( MWF_Config::UPLOAD_FILE_KEYS );
			$upload_file_hidden = $this->_get_upload_file_hidden( $upload_file_keys );
			$old_confirm_class  = $this->_get_old_confirm_class();
			$class_by_style     = $this->_get_class_by_style();

			return sprintf(
				'<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s %s">
					%s
				<!-- end .mw_wp_form --></div>',
				esc_attr( $this->form_key ),
				esc_attr( $this->view_flg . ' ' . $old_confirm_class ),
				$class_by_style,
				$Form->start() . do_shortcode( $content ) . $upload_file_hidden . $Form->end()
			);
		}
	}

Code file location:

mw-wp-form/mw-wp-form/classes/services/class.exec-shortcode.php

MW WP Form [mwform_complete_message] Shortcode

The ‘mwform_complete_message’ shortcode from the MW WP Form plugin is used to display a custom completion message after a form is submitted. This shortcode wraps the completion message in a div container with specific ID and class attributes. The ‘sprintf’ function formats the message, ensuring it is displayed correctly.

Shortcode: [mwform_complete_message]

Parameters

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

  • attributes – Custom settings for the form’s appearance and functionality
  • content – Text, HTML, or another shortcode that appears within the form
  • form_key – Unique key to identify specific form
  • view_flg – Flag to control the visibility of the form

Examples and Usage

Basic example – Displaying a completion message for a form using its unique form key.

[mwform_complete_message form_key="your_form_key"]Thank you for your submission![/mwform_complete_message]

Advanced examples

Displaying a completion message for a form using its form key and view flag. The view flag can be used to control the visibility of the form on the front-end.

[mwform_complete_message form_key="your_form_key" view_flg="1"]Thank you for your submission![/mwform_complete_message]

Displaying a completion message with custom content. This can be useful if you want to include additional information or instructions after the form has been submitted.

[mwform_complete_message form_key="your_form_key"]

Thank you for your submission! We will get back to you within 24 hours.

[/mwform_complete_message]

PHP Function Code

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

Shortcode line:

add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );

Shortcode PHP function:

function _mwform_complete_message( $attributes, $content = '' ) {
		return sprintf(
			'<div id="mw_wp_form_%s" class="mw_wp_form mw_wp_form_%s">
				%s
			<!-- end .mw_wp_form --></div>',
			esc_attr( $this->form_key ),
			esc_attr( $this->view_flg ),
			$content
		);
	}

Code file location:

mw-wp-form/mw-wp-form/classes/services/class.exec-shortcode.php

Conclusion

Now that you’ve learned how to embed the MW WP Form Plugin shortcodes, 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 *