Custom Validation Filter for one form only
-
I have this custom validation function that works well with CF7 form ID 585 but is blocking submission of all other CF7 forms. How can I make it only apply to form 585?
function faxormail_validation($result,$tag){ if ($_SERVER["REQUEST_METHOD"] == "POST"){ if (empty($_POST["addressroi"])&& empty($_POST["faxroi"]) ){ //In the result, the first variable in ()is the tag on the form where you want your //message to appeare in CF7 and the second is the message you want to send as the result $result->invalidate( "addressroi", "* * * * * *// YOU MUST ENTER AN MAILING ADDRESS OR FAX# //* * * * * *" ); } return $result; } } add_filter( 'wpcf7_validate_text', 'faxormail_validation', 10, 2 ); // text field add_filter( 'wpcf7_validate_text*', 'custom_text_validation_filter', 10, 2 ); //Req. text field.
The topic ‘Custom Validation Filter for one form only’ is closed to new replies.