Hi there! The title says it all. Here’s my code:
add_filter('acf/prepare_field', function( $field ) {
$field['required'] = false;
return $field;
}, 100);
This has the effect that the red asterisks go away, but on saving the post, it still forces me to fill all the fields. I don’t have any other acf/prepare_field
-filters running on my site.
acf/prepare_field is only run before the field is displayed on the admin and has no effect when ACF is validating the field since the field is not being displayed when it is being validated. So this filter will not work for what you’re trying to do.
You can set required to false when setting up the field
You can set required to false with acf/load_field https://www.advancedcustomfields.com/resources/acf-load_field/
Or you can set the field requited to false and then create an acf/validate_value filter for those cases when you want it to be required https://www.advancedcustomfields.com/resources/acf-validate_value/
Thank you John, acf/load_field
did the trick!