<?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: gform pre render and cookies</title>
		<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies</link>
		<description>Gravity Support Forums Topic: gform pre render and cookies</description>
		<language>en-US</language>
		<pubDate>Tue, 07 Apr 2026 08:46:22 +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/gform-pre-render-and-cookies" rel="self" type="application/rss+xml" />

		<item>
			<title>Jive Software on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-86503</link>
			<pubDate>Fri, 02 Nov 2012 04:06:14 +0000</pubDate>
			<dc:creator>Jive Software</dc:creator>
			<guid isPermaLink="false">86503@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Ignore my comment above...  It looks like you need to set the domain on the cookie...&#60;br /&#62;
setcookie(&#34;test&#34;, 1, time()+3600, &#34;/&#34;, str_replace('http://www','',get_bloginfo('url')) );
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jive Software on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-86497</link>
			<pubDate>Fri, 02 Nov 2012 03:55:27 +0000</pubDate>
			<dc:creator>Jive Software</dc:creator>
			<guid isPermaLink="false">86497@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am trying to do something similar...  &#60;/p&#62;
&#60;p&#62;I think the issue is the pre render hook happens after the http headers are sent...  you have to run your logic in the wordpress init hook... But then you have have the challange of getting the correct wp and gf data before the post has even been defined...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46838</link>
			<pubDate>Thu, 19 Jan 2012 08:48:56 +0000</pubDate>
			<dc:creator>Alex</dc:creator>
			<guid isPermaLink="false">46838@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;nobody know how to do this?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46597</link>
			<pubDate>Tue, 17 Jan 2012 16:47:58 +0000</pubDate>
			<dc:creator>Alex</dc:creator>
			<guid isPermaLink="false">46597@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;an update: i've been able to generate the input via jQuery. it's added into the selection which is display:none and is successfully added as a notification to the form.&#60;/p&#62;
&#60;p&#62;now, so I want to now get &#34;gsm&#34; into the routing option like so:&#60;br /&#62;
&#60;a href=&#34;http://dl.dropbox.com/u/14646537/image.png&#34; rel=&#34;nofollow&#34;&#62;http://dl.dropbox.com/u/14646537/image.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;and i found the Gform_admin_pre_render function here:&#60;br /&#62;
&#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Gform_admin_pre_render&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/documentation/page/Gform_admin_pre_render&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;this is the code i've made based on that link, but it doesn't seem to work (based on this being input 8 of form 2 and adding it to both functions.php and entry_detail.php):&#60;/p&#62;
&#60;p&#62;add_filter(&#34;gform_admin_pre_render_2&#34;, populate_dropdown);&#60;br /&#62;
function populate_dropdown($form){&#60;br /&#62;
    $items = array();&#60;/p&#62;
&#60;p&#62;	$items[] = array(&#34;value&#34; =&#38;gt; &#34;gsm&#34;, &#34;text&#34; =&#38;gt; &#34;gsm&#34;);&#60;br /&#62;
    foreach($form[&#34;fields&#34;] as &#38;amp;$field)&#60;br /&#62;
        if($field[&#34;id&#34;] == 8){&#60;br /&#62;
            $field[&#34;choices&#34;] = $items;&#60;br /&#62;
        }&#60;br /&#62;
    return $form;&#60;br /&#62;
}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46506</link>
			<pubDate>Mon, 16 Jan 2012 18:02:31 +0000</pubDate>
			<dc:creator>Alex</dc:creator>
			<guid isPermaLink="false">46506@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;tried it to no avail :(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46497</link>
			<pubDate>Mon, 16 Jan 2012 16:44:20 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">46497@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Try using the &#34;isset()&#34; function.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
if(isset($_COOKIE[&#38;#39;src&#38;#39;]){
   ...
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Alex on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46496</link>
			<pubDate>Mon, 16 Jan 2012 16:39:04 +0000</pubDate>
			<dc:creator>Alex</dc:creator>
			<guid isPermaLink="false">46496@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;there's definitely a record of the cookie as i can generate it via this line:&#60;/p&#62;
&#60;p&#62;	 $items[] = array(&#34;value&#34; =&#38;gt; &#34;gsm&#34;, &#34;text&#34; =&#38;gt; &#34;gsm&#34;);&#60;/p&#62;
&#60;p&#62;I can use jQuery to output the value with this code fine:&#60;/p&#62;
&#60;p&#62;&#38;lt;?php if($_COOKIE[&#34;src&#34;]){ ?&#38;gt;&#60;br /&#62;
&#38;lt;script type=&#34;text/javascript&#34;&#38;gt;&#60;br /&#62;
var src = &#38;lt;?php echo $_COOKIE[&#34;src&#34;];?&#38;gt;;&#60;br /&#62;
&#38;lt;/script&#38;gt;&#38;lt;?php } ?&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;script type=&#34;text/javascript&#34;&#38;gt;if(src){document.write(src);}&#38;lt;/script&#38;gt;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46492</link>
			<pubDate>Mon, 16 Jan 2012 16:17:00 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">46492@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;So the issue is the $_COOKIE global does not have a record of your cookie? Are you sure the cookie is being set correctly? I did not spot any issues with your code.&#60;/p&#62;
&#60;p&#62;To specify a different field ID per form, you could set up a simple array which would contain the form ID as the key and the field ID as the value:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
$field_ids = array(&#38;#39;1&#38;#39; =&#38;gt; &#38;#39;8&#38;#39;, &#38;#39;2&#38;#39; =&#38;gt; &#38;#39;14&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In this example, form ID points to field ID 8, form ID 2 points to field ID 14. Then you'd redo your field ID conditional like so:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
if($field[&#38;quot;id&#38;quot;] == $field_ids[$form[&#38;#39;id&#38;#39;]]){
    $field[&#38;quot;choices&#38;quot;] = $items;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Alex on "gform pre render and cookies"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform-pre-render-and-cookies#post-46487</link>
			<pubDate>Mon, 16 Jan 2012 14:53:06 +0000</pubDate>
			<dc:creator>Alex</dc:creator>
			<guid isPermaLink="false">46487@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am trying to make an email route based on whether a cookie is satisfied. However, it's harder than I thought. What trick am I missing? Here's what I have:&#60;/p&#62;
&#60;p&#62;cookie is $_COOKIE[&#34;src&#34;] and will have nothing if not triggered. To route the email I know that I need a selection enabled to use as conditional logic. I want to create this selection field and CSS it as display:none.&#60;/p&#62;
&#60;p&#62;I have been able to get the right code except here the function does not know that the cookie is set:&#60;/p&#62;
&#60;p&#62;if($_COOKIE[&#34;src&#34;]){&#60;br /&#62;
     $items[] = array(&#34;value&#34; =&#38;gt; &#34;gsm&#34;, &#34;text&#34; =&#38;gt; &#34;gsm&#34;);&#60;br /&#62;
} else {&#60;br /&#62;
	$items[] = array(&#34;value&#34; =&#38;gt; &#34;&#34;, &#34;text&#34; =&#38;gt; &#34;&#34;);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;this is the entire code:&#60;/p&#62;
&#60;p&#62;function my_custom_population_function($form){&#60;br /&#62;
    $items = array();&#60;br /&#62;
	if($_COOKIE[&#34;src&#34;]){&#60;br /&#62;
    	 $items[] = array(&#34;value&#34; =&#38;gt; &#34;gsm&#34;, &#34;text&#34; =&#38;gt; &#34;gsm&#34;);&#60;br /&#62;
	} else {&#60;br /&#62;
		$items[] = array(&#34;value&#34; =&#38;gt; &#34;&#34;, &#34;text&#34; =&#38;gt; &#34;&#34;);&#60;br /&#62;
	}&#60;br /&#62;
    foreach($form[&#34;fields&#34;] as &#38;amp;$field)&#60;br /&#62;
        if($field[&#34;id&#34;] == 8){&#60;br /&#62;
            $field[&#34;choices&#34;] = $items;&#60;br /&#62;
        }&#60;br /&#62;
    return $form;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;also, i will want to share this amongst all forms but the input number will not always be 8. any way around duplicate code?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
