Home › Forums › Feedback › Validation Code Example Turns non-required field into required › Reply To: Validation Code Example Turns non-required field into required
You could also do
if (!$valid || !$value) {
return $valid;
}
Most of the examples that the developer has given are supposed to be pretty basic, only including the necessary parts. There are many cases where if you use the code as given, for example many of the pre_get_post filter examples, that you’ll likely mess up other queries that need to be done because no checks are given to make sure the correct queries are altered.
As far as altering the code, no validation filter knows what the other filters are validating. ACF just does apply_filters(.....
. There isn’t even a guarantee that the internal ACF required field filter will actually run before your custom filter runs. It just runs through them all until one of them fails.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.