• Resolved webphp

    (@webphp)


    I think so many person have problem to email and confirm email not match in contact form 7 but now its solved.

    Go to contact form plugin in modules/text.php which looks like this

    if ( 'text*' == $type ) {
    	if ( '' == $_POST[$name] ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
    	}
    }

    replace with this

    if ( 'text*' == $type ) {
    	if ( '' == $_POST[$name] ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
    	} elseif ( array_key_exists($name.'_confirm', $_POST) ) {
    		if($_POST[$name] != $_POST[$name.'_confirm']) {
    			$result['valid'] = false;
    			$result['reason'][$name] = "Field not match";
    		}
    	}
    }

    this for text now for email

    if ( 'email' == $type || 'email*' == $type ) {
    	if ( 'email*' == $type && '' == $_POST[$name] ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
    	} elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = wpcf7_get_message( 'invalid_email' );
    	}
    }

    replace this

    if ( 'email' == $type || 'email*' == $type ) {
    	if ( 'email*' == $type && '' == $_POST[$name] ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
    	} elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = wpcf7_get_message( 'invalid_email' );
    	} elseif ( array_key_exists($name.'_confirm', $_POST) ) {
    		if($_POST[$name] != $_POST[$name.'_confirm']) {
    			$result['valid'] = false;
    			$result['reason'][$name] = "Email not match";
    		}
    	}
    }

    now when you add confirm field name make sure field have _confirm like this:

    [email* email]
    and match field
    [email* email_confirm]

    and for text

    [email* name]
    and match field
    [email* name_confirm]

    Hope its solve your problem

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    https://www.ads-software.com/extend/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • robgolbeck

    (@robgolbeck)

    But what happens when the plugin get’s updated? Will it overwrite your change? If so, you’ll have to go back and do all this again every time the plugin gets an update.

    I too need to have an email confirmation field. It would be great if this were a standard feature of the plugin. Judging by this hack, it doesn’t look like it would be very difficult to implement.

    Unfortunately, the developer has said in another thread that he has no plans to implement it because he thinks “it’s useless because everybody knows ‘Copy & Paste’“. It’s disheartening when developers assume that everybody uses the internet the way they do….

    My client constantly has people submitting email addresses with typos, then getting angry because they didn’t get a response. Clearly, this feature would work at solving that problem. Maybe it’s not 100% foolproof if people copy and paste an email address that has a typo, but at least it gives people a reason to double check.

    The Checkmail validation for Contact Form 7 plugin does a good job of checking for matching email fields, but it falls short on the error message by relying on the default generic ‘validation errors occurred…’ message, which doesn’t indicate what the error was, or which field.

Viewing 1 replies (of 1 total)
  • The topic ‘Problem Solved: Match two field in contact form 7’ is closed to new replies.