Support » Plugins » Add password validation to contact form 7

  • I would like to add custom post type loop to the functions.php. I’ve created PHP function to validate contact form (contact form 7). My function is simple, but it doesn’t solve my problem.

    My custom post type is created to define TITLE of password, so 1 custom post = 1 password.

    I would like to load my loop into my function but impossible for me.

    This is my code:

    function custom_email_validation_filter($result,$tag){
        $type = $tag['type'];
        $name = $tag['name'];
        if($name == 'your-id'){ // Only apply to fields with the form field name of "company-email"
            $the_value = $_POST[$name];
            if(( $the_value != 'test' ) && ( $the_value != 'test2' )) {
                $result['valid'] = false;
                $result['reason'][$name] = "Votre identifiant n'est pas correct";
        return $result;
    add_filter('wpcf7_validate_text','custom_email_validation_filter', 10, 2);
    add_filter('wpcf7_validate_text*', 'custom_email_validation_filter', 10, 2); 

    So “test” and “test2” are PASSWORD, but I would like to connect my custom post type to change this password.

  • The topic ‘Add password validation to contact form 7’ is closed to new replies.