How to pass data in Gravity Forms using filter hooks

Inside Gravity Forms documentation , you can find out that you can pass data into Gravity Forms by using any of the following 3 methods: hooks, query strings and shortcodes. Let me show you how to pass data using filter hooks. Basically, what you’re looking for is  gform_field_value_$parameter_name() filter. Note the $parameter_name.

The first thing we need is a filter, inside which we put our function that returns some data. There is an example on Gravity Forms website, a quite simple one.

The most important thing is to note that $parameter_name should match the returned variable. At least that’s what I think :).

Let me show you another example I created for this purpose. Nothing spectacular here, only the the function that returns the current post title:

Now, the question is how do we pass this info into Gravity forms, so that our field is populated dynamically? What we need is variable name, but without the $ sign, and you put this into parameter name inside the chosen field:

Or we can do the following (same thing, different variable):

In any case, you can see that variable name must match the parameter name. And that’s all there is – you are free to create your own custom functions.

Finally, this is the result you get in the front – these fields are populated by default when you open the page or post or any other type of custom post type where you put the Gravity form: