I have a validation function in my "functions.php" but even though it is called, it never changes the value in the database! It's always what was submitted by the browser! How do I fix this?
<?php
add_filter( 'wpcf7_validate_select', 'drc_wpcf7_validate_select' , 10, 2 );
add_filter( 'wpcf7_validate_select*', 'drc_wpcf7_validate_select' , 10, 2 );
function drc_wpcf7_validate_select( $result, $tag )
{
$type = $tag['type'];
$name = $tag['name'];
$value = $_POST[$name];
//Remove state if outside US
if ( strpos( $name , 'state' ) !== false )
{
$countryValue = $_POST[ "country" ];
//Not United States, remove state
if ( strcmp( $countryValue, "United States" ) != 0 )
{
//THIS CHANGES IT IN $_POST BUT IN THE DATABASE IT STILL SHOWS AS ALABAMA!!
unset($_POST[ $name ] );
$_POST[ $name ] = "(State Not Applicable)";
}
}
return $result;
}