Hi yanay,
Firstable:
I do not use the add_filter and function that originally come from the link that you gave.
I use the existence add_filter and just a part of the given function.
The code should be added in the text.php file. The location of this file is in the directory /wp-content/plugins/contact-form-7/modules
Some remarks:
Make a copy(as a backup) of your text.php file and deactivate the conatct-form-7 plugin first before you make changes in the code(or you can also edit the code offline). Don’t forget to activate it again when you’re ready.
Here it comes, so just follow these 2 steps:
1) search in the text.php file for the if-block statements as shown hereunder:
if ( 'email' == $tag->basetype ) {
if ( $tag->is_required() && '' == $value ) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
} elseif ( '' != $value && ! wpcf7_is_email( $value ) ) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
}
}
2) replace all the code mentioned in 1) with the if-block statements as shown hereunder:
if ( 'email' == $tag->basetype ) {
if ( $tag->is_required() && '' == $value ) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
} elseif ( '' != $value && ! wpcf7_is_email( $value ) ) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
} elseif ( 'your-email-confirm' == $tag->name ) {
if ( 'your-email-confirm' == $tag->name ) {
$your_email = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : '';
$your_email_confirm = isset( $_POST['your-email-confirm'] ) ? trim( $_POST['your-email-confirm'] ) : '';
if ( $your_email != "" && $your_email_confirm != "") {
if ( $your_email != $your_email_confirm ) {
$result->invalidate( $tag, "Are you sure this is the correct address?" );
}
}
}
}
}
I’ve tested and it works fine.
By the way, don’t expect too much from me because i am just a beginner.
Best regards and a happy new year
-
This reply was modified 8 years, 2 months ago by
Jan Dembowski. Reason: Fixed code block