This Contact Form 7 – Dynamic Text Extension shortcode returns a globally unique identifier (GUID). This is a great utility shortcode for forms that need unique identifiers for support tickets, receipts, reference numbers, and more without having to expose personally identifiable information (PII). The shortcode is simply CF7_guid with no other attributes, like this:
[CF7_guid]
Example
The dynamic text form tag when used in the form editor would look like this:
[dynamictext inputname "CF7_guid"]
Cache Compatibility
If the HTML of your webpage is being cached, preventing the server from processing the shortcode before displaying the form, then you can enable cache compatibility mode for this form tag.
However, this built-in shortcode is unique in that it does not make an AJAX request. Instead, it simply uses JavaScript to generate the GUID value. It uses the Crypto API which is available in most browsers.
Demo
Check it out! Below is a demo form with two form fields that both use the CF7_guid shortcode. The first is the default, processed on the server before the page loads while the second is done via JavaScript after the page loads. Every time you refresh this page, you should see totally different sequences—unless the page is cached (with fragment cache disabled), in which case, the first GUID shouldn’t change very often!
View Source Code
This shortcode was added to the Contact Form 7 – Dynamic Text Extension WordPress plugin in version 3.1.0. View the current source code for the server-side shortcode or for the client-side JavaScript function.
Can i change to readonly for user and they cant edit content in there?
Yes! You can use the
readonlyattribute in the dynamic text form tag like this:[dynamic_text my_guid readonly "CF7_guid"]or you can use the dynamic hidden form tag so the user can’t even see it. That’s useful if the GUID is just for internal purposes like generating support ticket numbers, license keys, etc.