Created
November 13, 2020 04:50
-
-
Save alt-karate/87db9b71d67f5c7cae965915926894cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//メールフォームの textarea に日本語が無ければ送信できない(contact form7) | |
add_filter('wpcf7_validate_textarea', 'wpcf7_validation_textarea_hiragana', 10, 2); | |
add_filter('wpcf7_validate_textarea*', 'wpcf7_validation_textarea_hiragana', 10, 2); | |
function wpcf7_validation_textarea_hiragana($result, $tag) | |
{ | |
$name = $tag['name']; | |
$value = (isset($_POST[$name])) ? (string) $_POST[$name] : ''; | |
if ($value !== '' && !preg_match('/[ぁ-ん]/u', $value)) { | |
$result['valid'] = false; | |
$result['reason'] = array($name => '日本語で入力してください。'); | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment