How to Display Shortcodes In Confirmation Messages

Would you like to display shortcodes in confirmation messages? By default, the confirmation message will not accept or process shortcodes. In this tutorial, we’ll show you how to use and display a shortcode inside your confirmation message using a small PHP snippet.

Installing Shortcodes Ultimate plugin

In this example, we’re going to add a QR Code shortcode for our confirmation message using a free plugin. This step is of course optional as you may already have a shortcodes plugin installed or built-in shortcodes available to you.

If you choose to use the plugin suggested in this tutorial, please download the Shortcodes Ultimate plugin and install it on your WordPress site.

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

Creating the shortcode

To create the QR shortcode needed, you’ll need to follow their documentation on how to create your QR shortcode.

When creating your shortcode, take note of all the customizable options that the plugin authors provide to change things like the size, colors, margin, etc. This way you can build your shortcode to look exactly how you’d like it.

[su_qrcode data="https://myexamplesite.com/refer-a-friend-discount" size="200" align="center" color="#F73F43" background="#ffffff"]

Creating the form

Once our shortcodes plugin is installed and activated, it’s time to create the form.

For any help needed on how to create a form, please review this documentation.

Once you’ve added all your form fields, from the Settings tab, click on Confirmations so that we can add our shortcode to the confirmation message.

Once on the Confirmations tab, click the Text tab where the confirmation message is and paste your shortcode under your message.

add your shortcode to the Text tab under the message of the confirmation message

Displaying the shortcode in the confirmation message

Now it’s time to add the snippet to our site.

If you need any help on how and where to add snippets to your site, please review this tutorial.

/**
 * Run shortcodes in the confirmation message.
 *
 * @link   https://wpforms.com/developers/how-to-display-shortcodes-inside-the-confirmation-message/
 */

function wpf_dev_shortcodes_to_confirmation( $content ) {
	
	return do_shortcode( $content );
}

add_filter( 'wpforms_process_smart_tags', 'wpf_dev_shortcodes_to_confirmation', 12, 1 );

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.

Reference Filter

wpforms_process_smart_tags