Reputation: 11
There was a situation where i had to create a custom hidden field in Contact Form 7 which captures page url. I used following code to achieve it.
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_sourceurl' );
wpcf7_add_shortcode('sourceurl', 'wpcf7_sourceurl_shortcode_handler', true);
function wpcf7_sourceurl_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
$html = '<input type="hidden" name="' . $name . '" value="http://' .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . '" />';
return $html;
}
It was working fine till i upgraded my Contact Form 7 to version 4.1.1
Any body can help to so that i can acheive the same in latest version of Contact Form 7 4.1.1 or 4.1.2.
Thank you,
~Waseem~
I
Upvotes: 1
Views: 994