I am using gravity forms and want to populate a field with a list of my categories in a drop down. I can do it with post titles, but not with the categories This is what I have so far, any help is appreciate.
add_filter("gform_pre_render", "populate_dropdown");
add_filter("gform_admin_pre_render", "populate_dropdown");
function populate_dropdown($form){
//only populating drop down for form id
if($form["id"] != 4)
return $form;
//get categores
global $post;
$category = get_the_category($post->ID);
//Creating drop down item array.
$items = array();
//Adding initial blank value.
$items[] = array("text" => "", "value" => "");
//Adding cat name to the items array
foreach($categorys as $category)
$items[] = array("value" => $category->cat_name, "text" => $category->cat_name);
//number is gform field id
foreach($form["fields"] as &$field)
if($field["id"] == 10){
$field["choices"] = $items;
}
return $form;
}