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.

POST remotely to a Gravity form?

  1. joshcanhelp
    Member

    I'd like to have one Gravity form submit another Gravity form with information from the first. I'm using WP's wp_remote_post function to send the required information. It doesn't seem to be submitting and I'm guessing it's related to the hidden fields added by the form I'm submitting to.

    If I'm using the same WP install for both forms, it seems like I should be able to generate unique IDs and states to create a valid submission. Any ideas on how to do that?

    Thank you!

    Posted 11 years ago on Friday August 24, 2012 | Permalink
  2. By hidden fields, I assume you mean the gform_unique_id and state_formID fields?

    Can you show us how you have accomplished what you have done so far? I don't know of anyone else who has posted a form programmatically like this and I'm sure the information you have would be useful to others. If you post what you have done so far, maybe we can help figure out what's going on.

    Posted 11 years ago on Saturday August 25, 2012 | Permalink
  3. joshcanhelp
    Member

    Those are the hidden fields I'm seeing, yes. There are a number of other ones, though, but if they are required, I think I know how to get them. Is there a function that generates those two fields, like a wp_nonce type one?

    The site isn't public quite yet so nothing to show. Even if I could, though, I don't think seeing the two forms would help much, they're both basic Gravity forms. The "magic" happens in a special page template. I'm using wp_remote_posts to send the fields from the first, successfully submitted form to the second one. It's fairly straight-forward but I think I need those hidden fields to have it submit properly.

    Posted 11 years ago on Saturday August 25, 2012 | Permalink
  4. If you take a look at the plugin source, you will see where those hidden fields are generated. Here is one from forms_model.php:

    [php]
        public static function get_form_unique_id($form_id){
            if(RGForms::post("gform_submit") == $form_id)
                return RGForms::post("gform_unique_id");
            else
                return uniqid();
        }

    Look at line 741 forms_model.php to see how that function is being used.

    Line 742 uses self:get_state which is found on lines 137 to 196. It's too long to post here, and you have the code already. Take a look at forms_model.php and I think you will find the pieces you're missing.

    Posted 11 years ago on Sunday August 26, 2012 | Permalink