<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Using Cookies to populate forms</title>
		<link>https://legacy.forums.gravityhelp.com/topic/using-cookies-to-populate-forms</link>
		<description>Gravity Support Forums Topic: Using Cookies to populate forms</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 18:21:03 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/using-cookies-to-populate-forms" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Using Cookies to populate forms"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-cookies-to-populate-forms#post-119542</link>
			<pubDate>Fri, 11 Jan 2013 13:06:50 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">119542@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'll leave the other topic open:&#60;br /&#62;
&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/little-hint-from-me-save-user-input-in-cookie-and-prepopulate-form#post-119539&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/little-hint-from-me-save-user-input-in-cookie-and-prepopulate-form#post-119539&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>chillybin on "Using Cookies to populate forms"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-cookies-to-populate-forms#post-118817</link>
			<pubDate>Thu, 10 Jan 2013 21:26:58 +0000</pubDate>
			<dc:creator>chillybin</dc:creator>
			<guid isPermaLink="false">118817@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;FYI, in order to get this working on my server (it was causing 500 errors) I have had to remove the &#38;amp; from before $field&#60;/p&#62;
&#60;p&#62;&#60;code&#62;foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field){&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;to &#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;code&#62;foreach($form[&#38;quot;fields&#38;quot;] as $field){&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Hope that helps
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Using Cookies to populate forms"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-cookies-to-populate-forms#post-74339</link>
			<pubDate>Fri, 07 Sep 2012 06:56:39 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">74339@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks for posting that code @Twig.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Twig Interactive on "Using Cookies to populate forms"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-cookies-to-populate-forms#post-74281</link>
			<pubDate>Thu, 06 Sep 2012 20:57:37 +0000</pubDate>
			<dc:creator>Twig Interactive</dc:creator>
			<guid isPermaLink="false">74281@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi - I'm sure you have this figured out by now, but cwidhelm on the other thread posted a great anonymous function to iterate all dynamic-enabled fields.&#60;/p&#62;
&#60;p&#62;I've copied it below - copy this into your functions.php. Then just edit your form in GF, and set a unique string for the dynamic parameter for each field.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function pre_submission_handler($form_meta) {
	foreach ($form_meta[&#38;quot;fields&#38;quot;] as $field) {
		if ($field[&#38;quot;allowsPrepopulate&#38;quot;] ){
			if (is_array($field[&#38;quot;inputs&#38;quot;]) ){
				foreach($field[&#38;quot;inputs&#38;quot;] as $sub){
					$val = $_POST[&#38;quot;input_&#38;quot; . str_replace(&#38;quot;.&#38;quot;, &#38;quot;_&#38;quot;, $sub[&#38;quot;id&#38;quot;])];
					setcookie(&#38;quot;gf_&#38;quot;.$sub[&#38;quot;name&#38;quot;], $val, time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);
				}
			}
			else {
				$val = $_POST[&#38;quot;input_&#38;quot; . $field[&#38;quot;id&#38;quot;]];
				setcookie(&#38;quot;gf_&#38;quot;.$field[&#38;quot;inputName&#38;quot;], $val, time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);
			}
		}
	}
	setcookie(&#38;quot;gf_form_meta&#38;quot;, serialize($form_meta[&#38;quot;fields&#38;quot;]), time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);
}
add_action(&#38;quot;gform_pre_submission&#38;quot;, &#38;quot;pre_submission_handler&#38;quot;);

function add_auto_update_filters($form){
	foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field){
		if( $field[&#38;quot;allowsPrepopulate&#38;quot;] ){
			if( is_array($field[&#38;quot;inputs&#38;quot;]) ){
				foreach($field[&#38;quot;inputs&#38;quot;] as $sub){
					$fieldName = $sub[&#38;quot;name&#38;quot;];
					add_filter(&#38;quot;gform_field_value_&#38;quot; . $fieldName, function($fieldName) use ($fieldName){
						return $_COOKIE[&#38;quot;gf_&#38;quot; . $fieldName];
					});
				}
			}
			else{
				$fieldName = $field[&#38;quot;inputName&#38;quot;];
				add_filter(&#38;quot;gform_field_value_&#38;quot; . $fieldName, function($fieldName) use ($fieldName){
					return $_COOKIE[&#38;quot;gf_&#38;quot; . $fieldName];
				});
			}
		}
	}
	return $form;
}
add_filter(&#38;quot;gform_pre_render&#38;quot;, &#38;quot;add_auto_update_filters&#38;quot;);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>cronkled on "Using Cookies to populate forms"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-cookies-to-populate-forms#post-54466</link>
			<pubDate>Fri, 06 Apr 2012 12:00:47 +0000</pubDate>
			<dc:creator>cronkled</dc:creator>
			<guid isPermaLink="false">54466@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi All, &#60;/p&#62;
&#60;p&#62;I'm attempting to set cookies to populate a form based on this thread: &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/little-hint-from-me-save-user-input-in-cookie-and-prepopulate-form&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/little-hint-from-me-save-user-input-in-cookie-and-prepopulate-form&#60;/a&#62; &#60;/p&#62;
&#60;p&#62;I've hit a dead-end when it comes to having the cookie set on multi-input fields. The cookie sets just fine if the filed has a single value (email, phone, etc.) but when it comes to fields like Name (first and last) and Address (Address 1, Address 2, City, State, Zip, Country) the cookie just isn't setting at all. &#60;/p&#62;
&#60;p&#62;Here's the code that I'm using to set the cookies: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;quot;gform_pre_submission&#38;quot;, &#38;quot;pre_submission_handler&#38;quot;);
function pre_submission_handler($form_meta) {
	$saveVars = array(&#38;quot;fname&#38;quot;, &#38;quot;lname&#38;quot;, &#38;quot;address&#38;quot;, &#38;quot;addtwo&#38;quot;, &#38;quot;phone&#38;quot;, &#38;quot;email&#38;quot;, &#38;quot;country&#38;quot;, &#38;quot;state&#38;quot;, &#38;quot;city&#38;quot;, &#38;quot;zip&#38;quot;);

    foreach($form_meta[&#38;quot;fields&#38;quot;] as $field) {
		if (in_array($field[&#38;quot;inputName&#38;quot;], $saveVars)) {
			setcookie(&#38;quot;gf_&#38;quot;.$field[&#38;quot;inputName&#38;quot;], $_POST[&#38;quot;input_&#38;quot; . $field[&#38;quot;id&#38;quot;]], time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);
		}
	}
setcookie(&#38;quot;gf_form_meta&#38;quot;, serialize($form_meta[&#38;#39;fields&#38;#39;]), time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Here are the filters: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_fname&#38;quot;, &#38;quot;populate_fname&#38;quot;);
function populate_fname() {
	return $_COOKIE[&#38;quot;gf_fname&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_lname&#38;quot;, &#38;quot;populate_lname&#38;quot;);
function populate_lname() {
	return $_COOKIE[&#38;quot;gf_lname&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_address&#38;quot;, &#38;quot;populate_address&#38;quot;);
function populate_address() {
	return $_COOKIE[&#38;quot;gf_address&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_addtwo&#38;quot;, &#38;quot;populate_addtwo&#38;quot;);
function populate_addtwo() {
	return $_COOKIE[&#38;quot;gf_addtwo&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_phone&#38;quot;, &#38;quot;populate_phone&#38;quot;);
function populate_phone() {
	return $_COOKIE[&#38;quot;gf_phone&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_email&#38;quot;, &#38;quot;populate_email&#38;quot;);
function populate_email() {
	return $_COOKIE[&#38;quot;gf_email&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_country&#38;quot;, &#38;quot;populate_country&#38;quot;);
function populate_country() {
	return $_COOKIE[&#38;quot;gf_country&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_state&#38;quot;, &#38;quot;populate_state&#38;quot;);
function populate_state() {
	return $_COOKIE[&#38;quot;gf_state&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_city&#38;quot;, &#38;quot;populate_city&#38;quot;);
function populate_city() {
	return $_COOKIE[&#38;quot;gf_city&#38;quot;];
}
add_filter(&#38;quot;gform_field_value_zip&#38;quot;, &#38;quot;populate_zip&#38;quot;);
function populate_zip() {
	return $_COOKIE[&#38;quot;gf_zip&#38;quot;];
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I do have the fields set to populate dynamically and am passing the field parameters correctly (fname, lname, etc.) &#60;/p&#62;
&#60;p&#62;Has anyone successfully gotten this to work? Any thoughts on how to pull it off?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
