WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
How do I change the value of a field in validation function? (1 post)

  1. donrhummy
    Member
    Posted 1 year ago #

    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;
    }

    http://wordpress.org/extend/plugins/contact-form-7/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic