Save and retrieve form fields with cookies
-
I read on http://sevenspark.com/free-stuff/contact-form-7-dynamic-text-extension-released about a fix for using cookies to store information.
I created a new short code and added it to the plugin file
/* Insert the referrer id via url or cookie */ function cf7_referrer(){ if(isset($_COOKIE["Referrer"])) { $val= $_COOKIE["Referrer"]; } else { $val = $_GET["id"]; } return $val; } add_shortcode('CF7_REFERRER', 'cf7_referrer');
and then added to header file
<?php if(isset($_COOKIE["Referrer"])) { } else { $refer = $_GET['id']; setcookie("Referrer", $refer, time()+3600); } ?>
I’m trying to replicate this on a website I’m building, but it doesn’t work.
What I did:
1) I pasted the first piece of code at the end of the file
wp\plugins\contact-form-7-dynamic-text-extension\wpcf7_dynamic_text.php
2) I pasted the second piece of code
wp\themes\twentytwelve\header.php
before the line </head>
3) I uploaded both files to the webserverThis didn’t work, so I guessed I needed to use the new shortcode CF7_REFERRER somewhere.
I looked in the Contact Form 7 plugin and changed the line
[dynamictext* your-name “CF7_GET key=’your-name'”]
into
[dynamictext* your-name “CF7_REFERRED key=’your-name'”]
but this didn’t help.I would be very greatful if someone could explain me which step I’m missing.
http://wordpress.org/extend/plugins/contact-form-7-dynamic-text-extension/
- The topic ‘Save and retrieve form fields with cookies’ is closed to new replies.