How to Display Shortcodes Inside the Confirmation Message

Overview

Would you like to display shortcodes inside your form’s confirmation message? By default, the confirmation message will not accept Smart Tags or shortcodes. In this tutorial, we’ll show you how to use and display a shortcode inside your confirmation message using PHP.

Setup

In this example, we’re going to add a QR code to the confirmation message using a free plugin. Please follow the steps below.

1) Installing the Shortcode Ultimate plugin

To begin, install the Shortcodes Ultimate plugin.

For details on how to add a plugin to your site, you might want to check out WPBeginner’s guide on how to install a plugin.

2) Adding the PHP

Next, add this PHP code snippet to your site.

/**
 * Run shortcodes in all the places where smart tags are processed.
 * @link   https://wpforms.com/developers/how-to-display-shortcodes-inside-the-confirmation-message/
 *
 * @param  string $content
 * @return string
 */
function wpf_smart_tags_shortcodes( $content ) {
	
	return do_shortcode( $content );
}
add_filter( 'wpforms_process_smart_tags', 'wpf_smart_tags_shortcodes', 12, 1 );

3) Creating the QR Code

To create the QR shortcode needed to go into your confirmation message, you’ll need to follow their documentation on how to customize your QR Code.

4) Adding the shortcode to your confirmation message

Once you’ve created your QR shortcode, open the form builder for the form you want to edit. Next, go to the form’s Settings » Confirmation tab.

Shortcode output appearance may be altered by form styles. Be sure to test!

Add the QR shortcode to your confirmation message

When your visitors complete your form they’ll now see the shortcode inside the confirmation message!

You can now display the shortcode inside the confirmation message

And that’s all you need to display any shortcode inside your confirmation messages. Would you like to style the confirmation message to match your branding? Take a look at our article on How to Remove Confirmation Message Box Styling.