Reputation: 13
how can For example fill form “a” and automatically fill form “b” without showing it to the user in gravity form?
Upvotes: 0
Views: 35
Reputation: 633
You can add something like the following to your functions.php code to copy entry values from Form A to a new entry in Form B
//after submission
add_action( 'gform_after_submission_20', 'submit_form_b', 10, 2 );//replace 20 with the form id of Form A
function submit_form_b($entry_a, $form ){
$entry_b = array(
"form_id" => '30',//replace 30 with the form id of Form B
"4" => $entry_a['1'],//replace "4" with the field id # from Form B. Replace '1' with the field id from Form A
"5" => $entry_a['2'],//replace "5" with the field id # from Form B. Replace '2' with the field id from Form A
"6" => $entry_a['3']//replace "6" with the field id # from Form B. Replace '3' with the field id from Form A
);
$create_entry = GFAPI::add_entry($entry_b);//this line creates a new entry for form B
}
Upvotes: 0