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.

Hidden Field and Custom Action

  1. markroskowske
    Member

    I need to add some hidden fields and a custom post action. I'm not sure how to add this.
    <input type="hidden" name="sample" value="(Unnamed Form 1)">
    <input type="hidden" name="elqSiteID" value="sample">

    The custom post action is to a url
    http://samle.t.eloqua.com/e/f2

    Posted 12 years ago on Tuesday August 21, 2012 | Permalink
  2. This should do the trick for you to create the hidden fields info:
    http://www.gravityhelp.com/documentation/page/Gform_field_input

    Posted 12 years ago on Tuesday August 21, 2012 | Permalink
  3. markroskowske
    Member

    Thanks. I will look at that.

    Do you know how to change the submit so it posts to a URL?

    Posted 12 years ago on Tuesday August 21, 2012 | Permalink
  4. David Peralty

    You can't change where a form submits, as it needs to submit on itself to have validation and entry creation happen.

    You can use gform_after_submission to push data to another URL or have the redirect go to another page, and include a query string.

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    Posted 12 years ago on Tuesday August 21, 2012 | Permalink
  5. markroskowske
    Member

    Thank you I will try these suggestions

    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  6. markroskowske
    Member

    I'm trying to create two hidden fields. The first one worked fine. So I copied it and changed the field id and values. Now I am getting this error. Any suggestions?

    Fatal error: Cannot redeclare tracker() (previously declared in /home/showme/public_html/wp-content/themes/rttheme15/functions.php:34) in /home/showme/public_html/wp-content/themes/rttheme15/functions.php on line 53

    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  7. markroskowske
    Member

    add_filter("gform_field_input", "tracker", 10, 5);
    function tracker($input, $field, $value, $lead_id, $form_id)
    {
          //because this will fire for every form/field, only do it when it is the specific form and field
    if ($form_id == 4 && $field["id"] == 5)
    	{
    		$input = '<input type="hidden" id="hidTracker" name="elqFormName" value="(Unnamed Form 1)">';
    		return $input;
    	}
    }
    add_filter("gform_field_input", "elqSite", 10, 5);
    function tracker($input, $field, $value, $lead_id, $form_id)
    {
          //because this will fire for every form/field, only do it when it is the specific form and field
    if ($form_id == 4 && $field["id"] == 6)
    	{
    		$input = '<input type="hidden" id="elqSiteID" name="elqFormName" value="638200148">';
    		return $input;
    	}
    }
    ?>
    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  8. Looks like you are declaring the same function twice: Screenshot

    Try changing the second one to match: elqSite so: function elqSite($input, $field, $value, $lead_id, $form_id)

    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  9. markroskowske
    Member

    Great that stopped the error.

    Now I'm trying to post after submission to a third party. I want to pass name, phone, and email address. DO I need to edit this in the form_display.php file? Here is the code I was going to use.

    add_action('gform_after_submission_4', 'post_to_third_party', 10, 2);
    function post_to_third_party($entry, $form) {
    
        $post_url = 'http://s638200148.t.eloqua.com/e/f2';
        $body = array(
            'first_name' => $entry['1.3'],
            'last_name' => $entry['1.6'],
            'phone' => $entry['2'],
    		'email' => $entry['3']
            );
    
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    
    }
    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  10. David Peralty

    You should never edit the form_display.php file. All of your hooks and functions go into your theme's functions.php file.

    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  11. rvturnage
    Member

    I'm attempting to do the same thing. However, I want to pass ALL fields, in all my forms, to a third party. Do I still need to specify each form field in the $body array as shown above where mark specifies first_name, last_name, etc.? Or would something like this work:
    http://pastie.org/private/yn41kndddzexydjhjorwq

    Posted 11 years ago on Thursday February 21, 2013 | Permalink
  12. This line:

    $post = get_post($entry["post_id"]);

    is returning the full content of a WordPress post, and that is what you are sending to the 3rd party. Is that what you intended to do?

    Posted 11 years ago on Saturday February 23, 2013 | Permalink
  13. rvturnage
    Member

    No, I am trying to submit the all the form fields to the third party, without having to manually specify each field in a $body array as Mark was showing in his situation. I need all forms on my site to also submit third party. there are a dozen different forms, all having different fields and field names, and we add new forms on a regular basis. I was hoping to access an existing array containing all of the submitted data when a form is submitted, so that I can pass that on using one function for all forms on my site.

    Thanks for your assistance.

    Posted 11 years ago on Saturday February 23, 2013 | Permalink
  14. Your code is incorrect in that case. What your code is doing is send a post body field to a 3rd party service. That's not gong to work.

    If you dump the $entry object in your code, you will see the names of all the fields and the data which was collected. You can send all those fields to thirdparty.com, if you want, but that is probably not what you mean to do. You probably have specific parameter names the 3rd party is looking for (for example, they probably want to see "name" rather than "input_1_3" or something.

    You will have to map the captured data from the entry to the specific parameter names that your 3rd party service wants to see.

    There is not an easy way to get all fields from all entries on all forms, including new forms, with just one function.

    Posted 11 years ago on Sunday February 24, 2013 | Permalink
  15. rvturnage
    Member

    That's what I was afraid of. Thanks Chris.

    Posted 11 years ago on Monday February 25, 2013 | Permalink

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