Created
August 9, 2011 06:25
-
-
Save bainternet/1133507 to your computer and use it in GitHub Desktop.
add current page url tag to content form 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* add this to your theme's functions.php file | |
*/ | |
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; | |
} | |
/* | |
* open your contact form and in the form part add: | |
"[sourceurl thesource]" | |
* | |
* and in the email part add: | |
"Source URL: <a href="[thesource]">[thesource]</a><br />" | |
*/ | |
and you are done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also update on row #9:
$name = $tag->name;
instead of
$name = $tag['name'];