3

I am using Ninja Forms with Webhooks add-on to submit form data to a third party API. Everything works fine, the data is submitted and I can see a response when running add-on in debug mode.

The question is how do I access an API response so I could use the response data as it returns user ID based on my submitted data. I need to submit that ID to the next page.

My form works as follows: 1. User inputs data 2. Form is submitted to API 3. User is redirected to another page

I need to be able to get user ID from an API response. Thanks!

sniurs
  • 135
  • 4
  • 13

1 Answers1

0

I realize you've long since moved on from this situation, but for others coming here from search results I have a partial answer.

Checking the Webhooks plugin code, there are several undocumented actions and filters, in particular nf_remote_get and nf_remote_post, both of which are actions that let you do something with the raw response.

function act_on_nf_remote_post_response( $response, $form_id ) {
    // output to debug log
    error_log( print_r( $response, true ) );
}
add_action( 'nf_remote_post', 'act_on_nf_remote_post_response', 10, 2 );

Unfortunately, it does not pass other data about the submission, only the ID of the form it belongs to, so it would take some gymnastics to store what you need and then reference it in a new page load while also ensuring it's the same user, possibly with some $_SESSION stuff.

cr0ybot
  • 3,960
  • 2
  • 20
  • 22