How to populate fields dynamically in Gravity Forms?

You can populate Gravity Forms fields of several methods (like passing parameters in the form short code).

Another solution is to create a function in your plugin or function file:

// get post ID
add_filter( 'gform_field_value_event_id', 'wpster_getevent_id' );
function wpster_getevent_id($value) {
	$field = get_the_ID();
	return $field;
// get ACF field value
add_filter( 'gform_field_value_event_price', 'wpster_getevent_price' );
function wpster_getevent_price($value) {
	$field = get_field('price');
	return $field;
// get session value
add_filter( 'gform_field_value_member_company', 'wpster_getmember_company' );
function wpster_getmember_company($value) {
	$field = $_SESSION['user_info']['company'];
	return $field;

In any case, you should select ‘allow field to be populated dynamically’ and use the ‘gform_field_value’.

If your function’s name is ‘gform_field_value_event_price’, you’ve to use ‘event_price’ in your form, to get the right value.

Submit a Comment

Your email address will not be published. Required fields are marked *