Redirection for Contact Form 7 Shortcodes

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

Before starting, here is an overview of the Redirection for Contact Form 7 Plugin and the shortcodes it provides:

Plugin Icon
Redirection for Contact Form 7

"Redirection for Contact Form 7 is a WordPress plugin designed to redirect users after a form submission. It's an essential tool for maintaining smooth, user-friendly site navigation."

★★★★☆ (194) Active Installs: 300000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [get_param]
  • [qs_date]

Redirection for Contact Form 7 [get_param] Shortcode

The wpcf7-redirect shortcode is a function that retrieves a specific parameter from the URL. The ‘get_param’ shortcode fetches a URL parameter specified in the ‘param’ attribute. It ensures the returned value is safe and free from harmful scripts. The shortcode is useful for passing information via URL parameters.

Shortcode: [get_param]

Parameters

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

  • param – Specifies the query string parameter to retrieve

Examples and Usage

Basic example – A simple usage of the shortcode to fetch a parameter value from the URL.

[get_param param="id" /]

This shortcode will fetch the value of the ‘id’ parameter from the URL. For instance, if your URL is ‘www.example.com/?id=123’, this shortcode will return ‘123’.

Advanced examples

Using the shortcode to fetch multiple parameters from the URL. The shortcode will return the value of the first parameter that it finds.

[get_param param="id, name, age" /]

In this example, the shortcode will first look for a parameter named ‘id’ in the URL. If it doesn’t find ‘id’, it will look for ‘name’, and if it doesn’t find ‘name’, it will look for ‘age’. The shortcode will return the value of the first parameter that it finds.

Remember, the parameters in the shortcode should be separated by commas and there should be no spaces between them. For instance, use ‘id,name,age’ instead of ‘id, name, age’.

PHP Function Code

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

Shortcode line:

add_shortcode( 'get_param', 'wpcf7r_get_param' );

Shortcode PHP function:

function wpcf7r_get_param( $atts ) {
	$atts  = shortcode_atts(
		array(
			'param' => '',
		),
		$atts,
		'wpcf7-redirect'
	);
	$param = '';

	if ( isset( $_GET[ $atts['param'] ] ) && $_GET[ $atts['param'] ] ) {
		$param = esc_attr( wp_kses( $_GET[ $atts['param'] ], array( '' ) ) );
	}

	return $param;
}

Code file location:

wpcf7-redirect/wpcf7-redirect/modules/cf7r-shortcode-get-param-field.php

Redirection for Contact Form 7 [qs_date] Shortcode

The ‘qs_date’ shortcode is part of the wpcf7-redirect plugin. It generates the current date in the ‘Ydm’ format. The shortcode uses the gmdate PHP function, which formats a GMT/UTC date/time. The ‘format’ parameter allows customization of the date format.

Shortcode: [qs_date]

Parameters

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

  • format – Defines the date format to be returned by the shortcode

Examples and Usage

Basic example – The shortcode is used to display the current date in the format ‘YearDayMonth’.

[qs_date format="Ydm" /]

Advanced examples

1. Displaying the current date in ‘Day-Month-Year’ format.

[qs_date format="dmY" /]

2. Displaying the current date in ‘Month/Day/Year’ format.

[qs_date format="m/d/Y" /]

3. Displaying the current date in ‘Year-Month-Day’ format.

[qs_date format="Y-m-d" /]

4. Displaying the current date in ‘Day-Month-Year Hour:Minute:Second’ format. This example uses more than two parameters.

[qs_date format="d-m-Y H:i:s" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'qs_date', 'qs_date' );

Shortcode PHP function:

function qs_date( $atts ) {
	$atts = shortcode_atts(
		array(
			'format' => 'Ydm',
		),
		$atts,
		'wpcf7-redirect'
	);

	return gmdate( $atts['format'], time() );
}

Code file location:

wpcf7-redirect/wpcf7-redirect/wpcf7r-functions.php

Conclusion

Now that you’ve learned how to embed the Redirection for Contact Form 7 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 *