<?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 gform_field_value with a global array?</title>
		<link>https://legacy.forums.gravityhelp.com/topic/using-gform_field_value-with-a-global-array</link>
		<description>Gravity Support Forums Topic: Using gform_field_value with a global array?</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 13:54:40 +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-gform_field_value-with-a-global-array" rel="self" type="application/rss+xml" />

		<item>
			<title>David Smith on "Using gform_field_value with a global array?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-gform_field_value-with-a-global-array#post-48896</link>
			<pubDate>Thu, 09 Feb 2012 17:19:08 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">48896@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi guys,&#60;/p&#62;
&#60;p&#62;This is a PHP scope issue. You need to declare that your global variable is available inside the hooked function, like so:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
add_filter(&#38;#39;gform_field_value_image_filename&#38;#39;, &#38;#39;get_filename&#38;#39;);
function get_filename($value){
    global $image;
    ...&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Now it will be available in the function per your second two examples.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ironsoup on "Using gform_field_value with a global array?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-gform_field_value-with-a-global-array#post-48854</link>
			<pubDate>Thu, 09 Feb 2012 14:43:32 +0000</pubDate>
			<dc:creator>ironsoup</dc:creator>
			<guid isPermaLink="false">48854@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'm having similar frustrations...hope someone can shed some light on this topic!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tdiaz1 on "Using gform_field_value with a global array?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-gform_field_value-with-a-global-array#post-48274</link>
			<pubDate>Fri, 03 Feb 2012 12:39:54 +0000</pubDate>
			<dc:creator>tdiaz1</dc:creator>
			<guid isPermaLink="false">48274@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I posted a similar thread, but I'll take a different approach: &#60;/p&#62;
&#60;p&#62;I've got various arrays available within my template, and want to put some of that data into the form being integrated into that same page:&#60;/p&#62;
&#60;p&#62;Viewing raw&#60;br /&#62;
&#38;lt;?php echo $image-&#38;gt;filename ?&#38;gt;&#60;br /&#62;
&#38;lt;?php echo $iptc['location'] ?&#38;gt; &#60;/p&#62;
&#60;p&#62;So this works:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php add_filter(&#38;#39;gform_field_value_image_filename&#38;#39;, &#38;#39;get_filename&#38;#39;); function get_filename($value){$variable = &#38;quot;FileName&#38;quot; ;return (string) $variable; } ?&#38;gt;
&#38;lt;?php echo $image-&#38;gt;filename ?&#38;gt;
    &#38;lt;?php gravity_form(1, false, false, false, &#38;#39;&#38;#39;, false); ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This however, will not: (I get nothing)&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php  add_filter(&#38;#39;gform_field_value_image_filename&#38;#39;, &#38;#39;get_filename&#38;#39;); function get_filename($value){$variable = $image-&#38;gt;filename ;return (string) $variable; } ?&#38;gt;
&#38;lt;?php echo $image-&#38;gt;filename ?&#38;gt;
    &#38;lt;?php gravity_form(1, false, false, false, &#38;#39;&#38;#39;, false); ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Or simply this doesn't work. (I get nothing)&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php  add_filter(&#38;#39;gform_field_value_image_filename&#38;#39;, &#38;#39;get_filename&#38;#39;); function get_filename($value) ; return $image-&#38;gt;filename;  ?&#38;gt;
&#38;lt;?php echo $image-&#38;gt;filename ?&#38;gt;
    &#38;lt;?php gravity_form(1, false, false, false, &#38;#39;&#38;#39;, false); ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The instances of the plain echo work just fine. So it's available &#34;right there&#34;. &#60;/p&#62;
&#60;p&#62;How do I get that information *into* the &#34;get_filename&#34; loop? It's obviously global.&#60;/p&#62;
&#60;p&#62;Otherwise, I have no clue what the purpose of this routine to pre-load data via the function is for- if all it works is with a hard coded &#34;return &#34;this data&#34; because you can do that directly in Gravity Forms. &#60;/p&#62;
&#60;p&#62;Here is the  whole page, with the Gravity Form call at the bottom:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://pastebin.com/b2eiNg67&#34; rel=&#34;nofollow&#34;&#62;http://pastebin.com/b2eiNg67&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
