Ask your WordPress questions! Pay money and get answers fast! (more info)

Gravity Forms and Custom Post Type plugins WordPress

  • SOLVED

Hi

We need development help with Gravity Forms and Custom Post Types front end forms - we're looking to populate a number of dropdowns in front end forms dynamically with various values drawn from a range of custom post types on a WordPress site we're building.

Thanks
Marcus

Answers (3)

2014-01-26

Arnav Joy answers:

Hello Markus,

Can you describe your work please.
Send me pm.

2014-01-26

Kyle answers:

This should work:

add_filter('gform_pre_render_x', 'populate_postS');
function populate_postS($form){


foreach($form["fields"] as &$field){

if($field["id"] == x2){
$args = array( );
$QS = new WP_Query( $args);
$field['choices'] = array();

foreach ($QS as $Q){

$name = $Q->post_title;
$val = $Q->ID;

$field['choices'][] = array( 'text' => $name, 'value' => $val);


}
}
}

return $form;
}


Replace x with your form id and x2 with the field id


Kyle comments:

Then you just have to add whatever arguments you need to pull certain posts to the $args array


marcusjwilson comments:

Thanks Kyle - yes, we'd used something similar but it wasn't populating properly. Arnav worked it out for us.

2014-01-26

Firoja_Imtosupport answers:

Hi Marcus,

Please can you provide a screenshot of which fields you want on frontend?