1. Home
  2. Car Demon Code Docs
  3. Admin Filters
  4. cd_validate_option_filter

cd_validate_option_filter

You can use this filter to add your own custom validation for Car Demon vehicle options.

apply_filters( ‘cd_validate_option_filter’, $value, $name );

add_filter( 'cd_validate_option_filter', 'my_validation', 10, 2 );
function my_validation( $value, $name ) {

    if ('body_style' === $name ) {

         if ( 'pickup' === $value ) {

             $value = 'Truck';

         }

    }

    return $value;
}

The above example checks to see if the current field being validated is the “body_style”. If it is then it checks to see if the value is “pickup”. If it is then it changes the value to “Truck”.

Was this article helpful to you? Yes No

How can we help?