How can I populate a (hidden) field in my Gravity Form with data that is sent to the form’s page via POST

Continuing the discussion from Transfer Parameters to a Gravity Form via POST:

How can I populate a (hidden) field in my Gravity Form with data that is sent to the form’s page via POST? To make it more clear: I have a very basic HTML form that sends its data via method="post" to a page containing my Gravity Form. Now I need to pick-up one of the values of the $_POST array in a hidden field of my Gravity Form so I can submit it together with my other form fields.

Any advice how to achieve this?

In the (now closed) thread, @chrishajer listed some really good options. Another which it sounds like your use case might benefit to look at is Gravity Flow’s Incoming Webhook step type. When you setup the incoming webhook feed, it provides you with options to define which fields in request are mapped to fields of the Gravity Form and can work with both hidden and administrative fields for added security.

With the entry created via that webhook, you could now populate “your other form fields” via a user input step in the workflow.

Hope that helps.
Jamie

Thanks Jamie for your advice! I will have a look at this. In the meantime I could solve this using the gform_field_value_$parameter_name hook like this:

In my functions.php I put these lines:

add_filter( 'gform_field_value_nominee', 'gf_set_nominee' );
function gf_set_nominee( $value ) {
  $nominee = '';
  if ( isset( $_POST['candidate'] ) )
    $nominee = $_POST['candidate'];
  return $nominee;
}

Then in my form, I activated dynamic population for my hidden field and set nominee as parameter name. Note that this matches the string I appended to the hook’s name: gform_field_value_nominee

Now this field will be populated with the value of the field candidate that is sent to my GF form’s page via POST.

Maybe this will help others that run into similar trouble.

Originally I was just wondering if there’s a way to do this without having to use a hook – just like dynamic populations works for $_GET parameters.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.