I posted a similar thread, but I'll take a different approach:
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:
Viewing raw
<?php echo $image->filename ?>
<?php echo $iptc['location'] ?>
So this works:
<?php add_filter('gform_field_value_image_filename', 'get_filename'); function get_filename($value){$variable = "FileName" ;return (string) $variable; } ?>
<?php echo $image->filename ?>
<?php gravity_form(1, false, false, false, '', false); ?>
This however, will not: (I get nothing)
<?php add_filter('gform_field_value_image_filename', 'get_filename'); function get_filename($value){$variable = $image->filename ;return (string) $variable; } ?>
<?php echo $image->filename ?>
<?php gravity_form(1, false, false, false, '', false); ?>
Or simply this doesn't work. (I get nothing)
<?php add_filter('gform_field_value_image_filename', 'get_filename'); function get_filename($value) ; return $image->filename; ?>
<?php echo $image->filename ?>
<?php gravity_form(1, false, false, false, '', false); ?>
The instances of the plain echo work just fine. So it's available "right there".
How do I get that information *into* the "get_filename" loop? It's obviously global.
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 "return "this data" because you can do that directly in Gravity Forms.
Here is the whole page, with the Gravity Form call at the bottom: