Dynamically Disable Contact Form 7 Field Validation

I just ran in to this problem too. This is how I solved it.

I'm using one of WPCF7's filters to alter the posted data before it is validated:

function alter_wpcf7_posted_data( $data ) {
    if($_POST['cpcm'] == "E-mail") {
        $_POST['tel'] = "Contact by email";
    }
    if($_POST['cpcm'] == "Phone Call") {
        $_POST['tel'] = "Contact by phone";
    }
    return $data;
}
add_filter("wpcf7_posted_data", "alter_wpcf7_posted_data");

That way, WPCF7's validation stage will think that the hidden field was in fact filled in.

Note: I haven't tested the code above specifically, but you should get the idea :)

Edit: The above code goes in the functions.php file of your theme


@Digital Brent, did you figure it out already?

I think you can skip email validation using JS

$('#myform').validate({
        ignore: ".wpcf7-list-item"
    });

P.S. Untested code.