Using Variables to Dynamically Populate Fields in Gravity Forms
I was building a form using Gravity Forms (aff. link) on the Rivers website the other day and came across the need to add a variable used in the back-end of the site and place the value in a form. Gravity Forms does allow you to dynamically set the value of a field and you can quickly do that using a query var. However, I didn't have the ability to set a query var in this case, nor did I want to.
After a bit of research I found a very nifty hook in Gravity Forms which is gform_field_value_my_parameter, where the "my_parameter" is replaced with the name you'd call use to dynamically full in the form - in other words if I wanted a parameter called user_location I would make the hookable action gform_field_value_user_location. I could then use "user_location" as the parameter to populate the field dynamically.
An example of this is:
add_filter('gform_field_value_my_parameter', 'my_custom_population_function'); function my_custom_population_function($value){ return 'yay!'; }
If you had a field being dynamically populated by "my_parameter", its resulting value will be "yay!".
This is very useful for passing information set by the user whilst on your website (login info, location, cart status, errors etc.) and linking it to the powerful Gravity Forms system.