gleenk
3/6/2015 - 5:46 PM

CF7 matching email

CF7 matching email

// Contact Form 7 Email Confirmation for fields your-email and email-confirm
// occorre chiamare i due campi come indicato di seguito

add_filter( 'wpcf7_validate_email', 'wpcf7_text_validation_filter_md', 10, 2 );
add_filter( 'wpcf7_validate_email*', 'wpcf7_text_validation_filter_md', 10, 2 );

function wpcf7_text_validation_filter_md( $result, $tag ) {
	$tag = new WPCF7_Shortcode( $tag );

	$name = $tag->name;

	$value = isset( $_POST[$name] )
		? trim( wp_unslash( strtr( (string) $_POST[$name], "\n", " " ) ) )
		: '';

	if ( 'email' == $tag->basetype ) {
		if ( $_POST['your-email'] != $_POST['email-confirm'] ) {
			$result->invalidate( $tag, wpcf7_get_message( 'invalid_url' ) ); //modified URL message in CF7 for this
		}
	}

	return $result;

}