Problem Solved: Match two field in contact form 7
-
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.]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problem Solved: Match two field in contact form 7’ is closed to new replies.