cssにinput[type=’email’]も追加
input[type='text'], textarea, .wpcf7-select,input[type='email']
ファンクションに
// Contact Form 7 に確認用メールアドレス入力欄を実装する
add_filter( ‘wpcf7_validate_email’, ‘wpcf7_text_validation_filter_extend’, 11, 2 );
add_filter( ‘wpcf7_validate_email*’, ‘wpcf7_text_validation_filter_extend’, 11, 2 );
function wpcf7_text_validation_filter_extend( $result, $tag ) {
$type = $tag[‘type’];
$name = $tag[‘name’];
$_POST[$name] = trim( strtr( (string) $_POST[$name], “\n”, ” ” ) );
if ( ‘email’ == $type || ‘email*’ == $type ) {
if (preg_match(‘/(.*)_confirm$/’, $name, $matches)){
$target_name = $matches[1];
if ($_POST[$name] != $_POST[$target_name]) {
$result[‘valid’] = false;
$result[‘reason’][$name] = ‘確認用のメールアドレスが一致していません’;
}
}
}
return $result;
}
コンタクトに
<tr><th>※メールアドレス確認</th> <td> [email* your-email_confirm]</td> </tr>