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.

Display result variable in confirmation message?

  1. bleckett
    Member

    Is there a way to add a value to the confirmation message after I get information back from a post?
    For example, in the functions.php I would add something like

    add_action("gform_post_submission", "send_post", 10, 2);
    function send_post$entry, $form)  {
     $user_fname = $entry['1.3'];
     $user_password = $entry['2'];
     $post_data= array('name' => $user_fname, 'pwd' => user_password);
     $client = new SoapClient("my.wsdl");
     $the_file = $client->getFileName($post_data);
    
    }

    I would like to display the the_file in the confirmation message.
    Can I use the gform_update_meta or is there another way?

    Then call it in the confirmation message?

    <p align="left">
    Dear {Name (First):1.3},
    </p>
    <p align="left">
    You file is at {the_file}
    </p>
    Posted 7 years ago on Saturday September 24, 2011 | Permalink
  2. You can store the link in the entry if you like. You have a start already using the gform_post_submission hook (runs after validation, before the entry is stored) but I think you want to use the gform_pre_submission hook (runs before the entry is stored.)

    Add a hidden form field in the form builder. Call it "The file" or whatever (it will be seen in the admin only.) Get the ID of that field. Then assign $the_form to that field using the pre_submission hook.

    Your code might look like this:
    [UPDATED LINK 24 September 2011]
    http://pastebin.com/5MQkXEmR

    Once you have the file information in your hidden field, use the drop down in the confirmation editor to insert that field into your confirmation message. The confirmation message might look like this:

    [html]
    <p style="text-align:left;">Dear {Name (First):1.3},</p>
    <p style="text-align:left;">Your file is at {The file:6}</p>

    Don't try to hand code the merge tag for the "The file" field: use the drop down.

    Let me know if you need more help working that out.

    Posted 7 years ago on Saturday September 24, 2011 | Permalink
  3. bleckett
    Member

    Thanks Chris - I think the gform_pre_submission is what I was looking for. I was using hidden fields, but nothing was populating.

    Also, I noticed that the drop down for the confirmation message only shows required fields. The hidden fields do not have confirmation as required parameter. I guess I can still add the field using the same syntax as other (required) fields by knowing the field IDs?

    BTW - just on a side note, what do the 'numbers' mean in the add_action function (and other functions). For example... some add_actions use 10, 2 in the docs, others don't have them at all. Is it something I need to be concerned about? (I couldn't find anything in the docs - FYI - I am using 1.6 beta).

    Thanks again for your help.

    Blaine

    Posted 7 years ago on Sunday September 25, 2011 | Permalink
  4. Regarding "confirmation message only shows required fields":

    I'm not able to verify that right now, but if that's the case, I usually use a drop down in another field where it will populate (like the content template or something) then copy the merge tag that was generated there, and paste it into the confirmation area. I think I ran into that before and worked around it but I can't get at my server right now. Once that's done, delete from whatever area you were using to generate the merge tag (since you really didn't want it there.) I try not to guess at the merge tags and always use the generated drop down to get it exactly right.

    The 10,2 are WordPress specific. 10 is the priority that the filter or action runs at. The 2 is the number of arguments the function accepts. As I type this, I realize that's wrong (I copied from your example with gform_post_submission which DOES accept 2 arguments.)

    Here's the updated code:
    http://pastebin.com/5MQkXEmR

    No priority and no number of arguments. The gform_pre_submission hook is documented here, in case I made any more mistakes.

    Here's the explanation of those numbers from WordPress:
    http://codex.wordpress.org/Function_Reference/add_action

    Sorry about the error. I think if you can get the merge tag correct for your confirmation message, you'll be in good shape.

    Posted 7 years ago on Sunday September 25, 2011 | Permalink