The Gravity forms gform_pre_render filter is executed before the form is displayed and can be used to manipulate the form the prior to rendering the form.
To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_pre_render_FORMID)
In this case, I am using the gform_pre_render filter on form 3, to populate field 38 which is a dropdown, with the terms for the taxonomy “business category
/Gravity Forms, populate a filter with all members
//Adds a filter to form id 3. Replace 3 with your actual form id
add_filter('gform_pre_render_3', 'lc_populate_member_dropdown');
function lc_populate_member_dropdown($form){
$terms = get_terms( array(
'taxonomy' => 'business-category',
'hide_empty' => false,
'orderby' =>'title',
'order' =>'ASC',
) );
//Creating drop down item array.
$items = array();
//Adding initial blank value.
$items[] = array("text" => "", "value" => "");
//Adding post titles to the items array
foreach($terms as $term)
$items[] = array(
"value" => $term->term_id,
"text" => $term->name
);
//Adding items to field id 38
foreach($form["fields"] as &$field)
if($field["id"] == 38){
$field["type"] = "select";
$field["choices"] = $items;
}
return $form;
}
By adding this snippet of code to the theme functions file, or to a small custom plugin, to make it theme independent, the form (Form ID 3 in this case) will have a dropdown populated with current taxonomy terms from the taxonomy “business-category” before it is rendered on the screen