I have a custom post type, and am using Elementor, PAFE, and ACF Pro, and Gravity Forms. For visually reasons I used PAFE/Elementor and at the end of my form process I am creating a Custom Post Type “Contract” and then once the contract is created it redirects to a page with a gravity form on it (hiding the ACF values). I want the Custom Field Values associated with the contract to shared with gravity forms but I am not successfully mapping it..
I have tried this but no luck. I am not sure which GravityForms filter I need to load in custom values.
Referencing:
https://docs.gravityforms.com/gform_field_value_parameter_name/
add_filter( 'gform_field_value', 'populate_fields');
function populate_fields( $value, $field, $name ) {
$values = array(
'pc' => get_field('pc',),
'dc' => get_field('dc'),
'tt' => get_field('tt'),
'rd' => get_field('rd'),
'vl' => get_field('vl'),
'on' => get_field('on'),
'fn' => get_field('fn'),
'ln' => get_field('ln'),
'cp' => get_field('cp'),
'ph' => get_field('ph'),
'e' => get_field('e'),
'apd' => get_field('apd'),
'tariff' => get_field('tariff'),
'c2c' => get_field('c2c'),
'tsc' => get_field('tsc'),
'awc' => get_field('awc'),
'pp_address' => get_field('pp_address'),
'pp_fn' => get_field('pp_fn'),
'pp_ln' => get_field('pp_ln'),
'pp_biz' => get_field('pp_biz'),
'pp_ph' => get_field('pp_ph'),
'pp_notes' => get_field('pp_notes'),
'do_address' => get_field('do_address'),
'do_fn' => get_field('do_fn'),
'do_ln' => get_field('do_ln'),
'do_biz' => get_field('do_biz'),
'do_notes' => get_field('do_notes')
);
return isset( $values[ $name ] ) ? $values[ $name ] : $value;
}
2
Answers
Thank you that did the trick, I was able to get it to work like this, but I didn't assign variable to save some time writing code probably not the best practice in terms of performance but it works. :
You must check your ACF fields and gravity form key are valid or not. You can also pass the id while getting data from the get_field() like as below:
This example shows a variety of $post_id values to get a value from a post, user, term, and option.
I hope it would help you out.