Quantcast
Channel: WordPress.org Forums » [Contact Form 7] Support
Viewing all articles
Browse latest Browse all 49500

webphp on "[Plugin: Contact Form 7] Problem Solved: Match two field in contact form 7"

$
0
0

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.]

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


Viewing all articles
Browse latest Browse all 49500

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>