Display a hidden input allowing you to pass custom data to the current form. The field wrapper won’t be displayed.
Setting name | Description |
Value | Define a custom value |
Value can then be retrieved using the common get_field()
function. Usage example:
$hidden = get_field('hidden');
// my_value
It is possible to change the field value using the acf/prepare_field
hook. Note that the value will saved like any other custom meta. Usage example:
/*
* ACF Prepare Field
* https://www.advancedcustomfields.com/resources/acf-prepare_field/
*/
add_filter('acf/prepare_field/name=hidden', 'my_acf_hidden');
function my_acf_hidden($field){
$field['default_value'] = 'my_value';
// Or:
$field['value'] = 'my_value';
return $field;
}
To prevent the value from being saved as a custom meta, you can use the acf/update_value
hook and return null
. Usage example:
/*
* ACF Update Value
* https://www.advancedcustomfields.com/resources/acf-update_value/
*/
add_filter('acf/update_value/name=hidden', 'my_acf_hidden_update', 10, 3);
function my_acf_hidden_update($value, $post_id, $field){
return null;
}