I am not familiar with gravity form hooks.
I have created 2 sign up process forms that are displayed in a single modal but called in different divs. I wanted to send these data from 2 forms to a third party application using gform_after_submission send entry data to third-party after submitting a specific form (last form).
However doing this:
add_action( 'gform_after_submission_2', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {
$post_url = 'http://thirdparty.com';
$body = array(
'first_name' => rgar( $entry, '1.3' ),
'last_name' => rgar( $entry, '1.6' ),
'message' => rgar( $entry, '3' ),
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
will only allow me to get entry fields from the form id specified.
How would it be possible that I will get entries from other forms too so that I could include and post it to third party url?
Thanks ahead.
Because you are specifying the form ID in the add_action itself, you are only running your function when the Gravity Form, with an ID of 2, is submitted. If you want it to run for multiple submissions, but then limit it to specific form IDs, then something more like this:
You might need to use
$form['id']
in the event you aren’t dealing with the object. One of them will work. The downside is you must know the ID of the forms you want to work with. This is easily found in the backend when viewing the table of forms you’ve created, but it is what it is…If you are saving form data to the same post maybe you can get the date based on post id