<?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: Assigning hidden values from template</title>
		<link>https://legacy.forums.gravityhelp.com/topic/assigning-hidden-values-from-template</link>
		<description>Gravity Support Forums Topic: Assigning hidden values from template</description>
		<language>en-US</language>
		<pubDate>Sat, 02 May 2026 18:26:39 +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/assigning-hidden-values-from-template" rel="self" type="application/rss+xml" />

		<item>
			<title>trevor on "Assigning hidden values from template"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/assigning-hidden-values-from-template#post-83144</link>
			<pubDate>Wed, 24 Oct 2012 02:30:23 +0000</pubDate>
			<dc:creator>trevor</dc:creator>
			<guid isPermaLink="false">83144@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Resolved.&#60;/p&#62;
&#60;p&#62;I finally got the post to auto populate using the gform_pre_render hook.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter( &#38;#39;gform_pre_render_1&#38;#39;, &#38;#39;auto_pop_form_function&#38;#39; );

function auto_pop_form_function( $form ){

	global $wp_query;
	$thePostID = $wp_query-&#38;gt;post-&#38;gt;ID;
	$postInfo = get_post_meta( $thePostID, &#38;#39;custom-post-data&#38;#39;, true);

	foreach($form[&#38;#39;fields&#38;#39;] as &#38;amp;$field)
		if($field[&#38;#39;id&#38;#39;] == 1){
			$field[&#38;#39;defaultValue&#38;#39;] = $postInfo;
		}
		else if ($field[&#38;quot;id&#38;quot;] == 4){
			$field[&#38;quot;defaultValue&#38;quot;] = &#38;#39;hard coded text string&#38;#39;;
		}

	    return $form;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Using $field['defaultValue'] to set my value will work for my purposes.  I am still not sure how to change a field value.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>trevor on "Assigning hidden values from template"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/assigning-hidden-values-from-template#post-82829</link>
			<pubDate>Tue, 23 Oct 2012 01:58:58 +0000</pubDate>
			<dc:creator>trevor</dc:creator>
			<guid isPermaLink="false">82829@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I want to assign a different ebook title to different post pages. I am trying to set $field_data when I call the form, but it is not getting set.  I have tried calling the form two different ways...&#60;/p&#62;
&#60;p&#62;First by assigning array values to $field_values when I call the form.&#60;br /&#62;
&#60;code&#62;gravity_form(1, false, true, $field_values = array( &#38;quot;ebook-title&#38;quot; =&#38;gt; $ebooktitle, &#38;quot;Phone&#38;quot; =&#38;gt; &#38;quot;(907)555-1234&#38;quot; ), &#38;#39;&#38;#39;, false)&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Second by assigning the array to a variable then using the variable to set $field_values.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;$tpd_field_values_set = array( &#38;quot;ebook-title&#38;quot; =&#38;gt; $ebooktitle, &#38;quot;Phone&#38;quot; =&#38;gt; &#38;quot;(907)555-1234&#38;quot; );
gravity_form(1, false, true, $field_values = $tpd_field_values_set, &#38;#39;&#38;#39;, false);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The form shows up on the page but none of the data is there.  I selected &#34;Allow field to be populated dynamically&#34;.  The variable $ebooktitle is set.&#60;/p&#62;
&#60;p&#62;How do I use data from my post to populate on form when the post loads.&#60;/p&#62;
&#60;p&#62;Thanks for your help&#60;br /&#62;
Trevor
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
