While using a front end form, could get values from a query?
Something like this: http://example.com/form?foo_name=bar
, so when you click on the link that will take you to the form, the field called foo_name
will be fille by default with the value bar
.
Hi @gabyferman,
Hmm… I believe that this should be possible using the acf/load_value
filter. The code should be as shown below:
add_filter('acf/load_value/key=<field_key>', 'my_text_value', 10, 3);
function my_text_value($value, $post_id, $field) {
$value = isset($_GET['foo_name'])?$_GET['foo_name']:'default_value';
return $value;
}
Have a look at the documentation for more information on this filter: http://www.advancedcustomfields.com/resources/acfload_value/
Hi,
I tried this approach, and while it work with the form it messes up all the other entries, they all get default_value
as the foo_name
field value
duh, I though default_value was a type of variable for ACF :$ I just change it for $value
and it worked.
function my_text_value_group_type( $value, $post_id, $field ) {
$value = isset( $_GET['foo_name'] ) ? $_GET['foo_name'] : $value;
return $value;
}
add_filter('acf/load_value/key=<field_key>', 'my_text_value_group_type', 10, 3);
Thank you