How to Display Shortcodes In Confirmation Messages

Would you like to use shortcodes in your form confirmation messages? By default, WPForms doesn’t process shortcodes in confirmation messages, but you can enable this functionality with a simple PHP snippet.

This guide will show you how to display shortcodes, such as QR codes, in your form’s confirmation message.

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"]

Setting Up Your Form

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

If you need help creating a form, please see our guide on creating your first form.

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

Enabling Shortcode Processing

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

If you’re not sure how to add custom code, please see our guide on how to add code snippets.

/**
 * Enable 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 removing box styling of confirmation messages.

Reference Filter

wpforms_process_smart_tags