Word Count: 184
  • Post category:Alicia Pilates
  • Post last modified:2021-07-19

Add dynamic text to CF7

The Dynamic Text Extension (DTX) is a very simple plugin that extends the functionality of Contact Form 7. Out of the box in Contact Form 7, you can set a static default value for text inputs. The DTX allows you to set this default dynamically, with the value generated by a shortcode.

DXT also support hidden fields. It is useful in passing dynamic data to the email body.

Shortcodes

A shortcode is a string of text that is processed and replaced by the output of a PHP function. WordPress shortcodes are denoted by square brackets surrounding the text string.

DXT provides built-in shortcodes that can extract the post information, e.g. title, author, etc… See details here.

Developers can also build custom shortcodes. See details here.

Example – add page title as a hidden field

In this example, the CF7 form will include the title of its page and pass onto the mail using the shortcode [from-page] in the mail body.

[text* your-name] 
[tel* your-phone] 
[email* your-email] 
[textarea your-message] 
[submit "CONTACT US"]
[dynamichidden from-page "CF7_get_post_var key='title'"]