Input default value from URL
We will get contact form 7 default input value by url. We will get URL data by `default:get
option.
Example Shortcode:-
[text* your-name default:get]
URL is http://example.com/contact/?your-name=Muhammed+Arshid
How to add shortcode as default input values
Install Contact Form 7 Dynamic Text addon. Then we can add a shortcode “dynamictext” or “dynamichidden“.
Example
[dynamictext your-name value=”example-shortcode key=’day'”]
Add custom shortcode function in selected theme functions.php
1 2 3 4 5 6 7 8 9 10 |
add_shortcode('example-shortcode', 'example_shortcode'); function example_shortcode( $atts ){ if(isset($atts['key']) && $atts['key'] == 'day'){ return date('l'); } if(isset($atts['key']) && $atts['key'] == 'year'){ return date('Y'); } } |