I'm successfully using Advanced Custom Fields and Gravity Forms in unison. I'm trying to take an extra step with the dynamic population and pre-populate a field from an Advanced Custom Field in a specific post. For example, if i wanted to find an ACF called "field_slug" from post id #1, I would put this in my template:
<?php echo the_field('field_slug', 1); ?>
I hoped I could take this and put it into the following tutorial I found on this forum:
/* Dynamic Population from Custom Field */
add_filter("gform_field_stock_num", "populate_stock");
function populate_stock($value){
global $post;
return get_post_meta($post->ID, 'stock_num', true);
}
First, I simplified it to make sure it was filling out the right input field (it was, and "woo" appeared just fine in the form's desired input field).
add_filter('gform_field_value_trend_values', 'trend_auto_populate');
function trend_auto_populate($value){
return 'woo';
}
However, when I try to add a truly dynamic field like ACF the_field(), The values do not appear in the input, they appear outside of the box near the header. Here is the final code I've put together. Again, the $value comes back just fine, but it doesn't "return" inside the input as i had hoped.
add_filter('gform_field_value_trend_values', 'trend_auto_populate');
function trend_auto_populate($value){
$recent_snapshot = 1373;
$value = the_field('trend_values', $recent_snapshot);
return $value;
}
So my question is, how can I pre-populate an ADVANCED custom field rather than just a string?