WPForms Custom Smart Tags

WPForms comes with many pre-built smart tags, which are like shortcodes for your form. You can also add your own.

The following code will turn {my_smart_tag} into “Testing 1 2 3”. You can replace the tag name and value with whatever you’d like to use.

<?php
/**
* Custom Smart Tags
*
* @author Bill Erickson
* @see http://www.billerickson.net/code/wpforms-custom-smart-tags
*/
function ea_custom_smart_tags( $content, $tag ) {
if( 'my_smart_tag' == $tag ) {
$value = 'Testing 1 2 3';
$content = str_replace( '{' . $tag . '}', $value, $content );
}
return $content;
}
add_filter( 'wpforms_smart_tag_process', 'ea_custom_smart_tags', 10, 2 );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk