Question :
Contact form 7 has some shortcodes, like [_date] to get todays date. But I want to display the date one week from now.
So I need to create a custom shortcode to Contact form 7 that takes say [next_week] and in the received email the correct date is displayed.
Where and how do I create custom shortcodes to Contact form 7?
Solution code for : Wordpress Contact form 7 custom shortcodes
Adding the following to your functions.php
Now in the "Form" field in CF7 GUI type
Now you can use
Contact form 7 has some shortcodes, like [_date] to get todays date. But I want to display the date one week from now.
So I need to create a custom shortcode to Contact form 7 that takes say [next_week] and in the received email the correct date is displayed.
Where and how do I create custom shortcodes to Contact form 7?
Solution code for : Wordpress Contact form 7 custom shortcodes
Adding the following to your functions.php
1 2 3 4 5 6 7 8 9 10 11 12 | wpcf7_add_shortcode( 'custom_date' , 'wpcf7_custom_date_shortcode_handler' , true); function wpcf7_custom_date_shortcode_handler( $tag ) { if (! is_array ( $tag )) return '' ; $name = $tag [ 'name' ]; if ( empty ( $name )) return '' ; $next_week = date ( 'Y-m-d' , time() + (60*60*24*7)); $html = '<input name="' . $name . '" type="hidden" value="' . $next_week . '">' ; return $html ; } |
[custom_date next_week]
Now you can use
[next_week]
in the message body.
No comments:
Post a Comment