PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

gform_after_submission output

  1. Hello,

    I'm using gform_after_submission to take input from a form and execute an API query to a third-party application for information. I would like to send the output from the function to the confirmation message of the form but I'm not clear on how to accomplish that. As it stands, I'm just echoing the output as part of the function, which sends the text to the page but outside of the Wordpress loop and it doesn't look so nice. Is there anyway that I can pass the output from my third-party application to the gform_confirmation hook so that it is displayed nicely within the loop?

    Thanks for any suggestions.

    -tomdaq

    Posted 11 years ago on Thursday February 7, 2013 | Permalink
  2. Can you show us the code you're using currently? I'm not clear what information you want to use in the confirmation message.

    Posted 11 years ago on Friday February 8, 2013 | Permalink
  3. Sure. You can see an example of what I'm doing here: http://pastebin.com/akjrhHGY

    The majority of the code is insignificant. What matters is the echo statements near the end. The information in the echo statements need to be returned in the confirmation message for the form. As it is, the information is echoed to the confirmation page but it is echoed outside of the loop. Let me know if more clarification is needed.

    Thanks,
    tomdaq

    Posted 11 years ago on Friday February 8, 2013 | Permalink
  4. When you say "outside the loop" do you mean actually just near the top of the page, since you're just echoing it? You want it to be nicely formatted in the confirmation message area?

    Posted 11 years ago on Saturday February 9, 2013 | Permalink
  5. Yes, that's exactly the issue. I can't just put the "Your account has been updated successfully..." message in the confirmation of the form. This function is just one example. Many of my other functions output dynamic information, which I need to send back to the user in the confirmation message area as you said so that it is nicely formatted instead of just being dumped in the top of the page. I'm guessing I'm either missing something really simple, or I just need to take a different approach altogether.

    I considered using the gform_confirmation hook to execute the function instead of using the gform_after_submission approach that I currently have but I'm not sure if I can still get the entry data from the form. Would I use lead[] instead of entry[]?

    Thanks for your help.
    -tomdaq

    Posted 11 years ago on Saturday February 9, 2013 | Permalink
  6. gform_confirmation uses the $lead object, with is synonymous with the $entry and the usage is the same:

    [php]
    // usage
    function custom_confirmation($confirmation, $form, $lead, $ajax){

    To display the information inside the confirmation message you will need to return the information rather than echo it. Echo happens immediately. If you return it, then you can use it by echoing it in your confirmation message.

    Posted 11 years ago on Sunday February 10, 2013 | Permalink
  7. Chris, seriously! You're a work horse man. I really appreciate your help.

    Best,
    tomdaq

    Posted 11 years ago on Sunday February 10, 2013 | Permalink
  8. Let us know how that works out for you or if you need additional assistance.

    Posted 11 years ago on Sunday February 10, 2013 | Permalink
  9. Update: I switched my function to a filter using gform_confirmation and now the text I return appears nicely formatted within the page.

    Thanks again for all your help.

    -tomdaq

    Posted 11 years ago on Wednesday February 20, 2013 | Permalink
  10. Thank you for the update.

    Posted 11 years ago on Saturday February 23, 2013 | Permalink

This topic has been resolved and has been closed to new replies.