Hi,
I have the following function in my theme function.php file:
---------------------------------------------------------------
[php]
if(isset($_POST['input_13'])){
$my_value=$_POST['input_13'];
}
add_filter('gform_field_value_select_stuff', 'select_stuff');
function select_stuff($value){
global $my_value;
$result=mysql_query("SELECT user_email
FROM wp_users
LEFT JOIN wp_usermeta
ON wp_users.ID=wp_usermeta.user_id
WHERE wp_usermeta.meta_key='$my_value'
");
while($row = mysql_fetch_array($result)){
return $row['user_email'];
}
if(mysql_num_rows($result)==0){
return "No Match";
}
}
---------------------------------------------------------------
I have two questions:
1. the code works as expected when i put this in a page : <?php echo select_stuff() ?>
But when I use the parameter name 'select_stuff' (without the '') in a gravity form field in the 'parameter name' field to dynamically populate the field, it shows the exception: "No Match". It's like my $my_value all of a sudden is not remembered when using the parameter method in a form field. I know this because when I use a static value instead of $my_value it DOES show the result inside the gravity forms field.
2. My second issue is that 'return' in this function only outputs 1 value, while using echo or print shows all available matches (and there are multiple).
Can anybody help me out with these two problems?
Thanks in advance!