Support

Account

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.