• Resolved mrayoub86

    (@mrayoub86)


    Hey, is there a way to make a custom validation like the standard contact form 7 validation? (add_filter( ‘wpcf7_validate_file’, ‘custom_file_validation_filter’, 20, 2 );)

    Tahnks

Viewing 1 replies (of 1 total)
  • Plugin Author Glen Don Mongaya

    (@glenwpcoder)

    Hello @mrayoub86 ,

    You can try and use this filter

    Example below to check if files is empty.

    add_filter('wpcf7_validate_mfile', 'custom_file_validation_filter', 20, 2 );
    add_filter('wpcf7_validate_mfile*', 'custom_file_validation_filter', 20, 2 );
    
    function custom_file_validation_filter( $result, $tag ) {
    $name = $tag->name;
    if( empty( $_POST[ $name ] ) && $tag->is_required() ){
     $result->invalidate( $tag, 'File upload is required');
     return $result;
    }
    
    return $result;
    }
Viewing 1 replies (of 1 total)

The topic ‘Custom validation’ is closed to new replies.