ACF form – Getting default values from HTTP GET variables
-
Hello, I am trying out the free version of ACF before deciding on purchasing the Pro version and have a question; how to get default values from the context (url) when using ACF forms. As an example of what I am looking for; ContactForm 7 has this feature where you can get the default value of a form input field from a url;
To get the default value from HTTP GET variables, add default:get option to the form-tag. [text* your-name default:get]
With ACF forms how does one go about doing something similar in getting values from a url. The ACF documentation has something that seems related at https://www.advancedcustomfields.com/resources/acf-load_value/. Is this the way to go or is there a simpler approach? Below is the code from this link. Thanks
<?php
function my_acf_load_value( $value, $post_id, $field ) {
if( is_string($value) ) {
$value = str_replace( ‘Old Company Name’, ‘New Company Name’, $value );
}
return $value;
}// Apply to all fields.
add_filter(‘acf/load_value’, ‘my_acf_load_value’, 10, 3);// Apply to textarea fields.
// add_filter(‘acf/load_value/type=textarea’, ‘my_acf_load_value’, 10, 3);// Apply to fields named “hero_text”.
// add_filter(‘acf/load_value/name=hero_text’, ‘my_acf_load_value’, 10, 3);// Apply to field with key “field_123abcf”.
// add_filter(‘acf/load_value/key=field_123abcf’, ‘my_acf_load_value’, 10, 3);The page I need help with: [log in to see the link]
- The topic ‘ACF form – Getting default values from HTTP GET variables’ is closed to new replies.