Contact Form 7とGoogle reCAPTCHA V3を連携する方法
![Contact Form 7とGoogle reCAPTCHA V3を連携する方法](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha.png)
Contact Form 7経由の迷惑メールが1日200件以上届くようになったので、Google reCAPTCHA V3を導入しました。
※導入して今日で3日目。
迷惑メール0件。
以下、Contact Form 7とGoogle reCAPTCHA V3を連携する方法です。
eCAPTCHA V3のキーを取得
reCAPTCHA V3の公式サイトからキーを取得します。
https://www.google.com/recaptcha/about/
![Google reCAPTCHA V3 公式サイト](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha101.jpg)
「v3 Admin Console」をクリック。
![Google reCAPTCHA V3 公式サイト 情報入力画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha102.jpg)
必要事項を入力・選択して、「送信」をクリック。
- ラベル:任意の名前を入力
- reCAPTCHA:スコアベースを選択
- ドメイン:ドメインを入力
![Google reCAPTCHA V3 公式サイト キー取得完了画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha104.jpg)
サイトキーとシークレットキーを取得できました。
後ほど、この2つのキーを使って連携します。
Contact Form 7とreCAPTCHAを連携
WordPressの管理画面からContact Form 7とreCAPTCHAを連携します。
![WordPress Contact Form 7](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha201.jpg)
メニューの「お問い合わせ」>「インテグレーション」をクリック。
![WordPress Contact Form 7 インテグレーション 選択画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha202.jpg)
reCAPTCHA(V3)の「インテグレーションのセットアップ」をクリック。
![WordPress Contact Form 7 インテグレーション reCAPTCHAのキー入力画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha203.jpg)
先ほど取得したサイトキーとシークレットキーを貼り付けて、「変更を保存」をクリック。
![WordPress Contact Form 7 インテグレーション reCAPTCHAと連携完了画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha204.jpg)
Contact Form 7とreCAPTCHAを連携できました。
reCAPTCHAのバッジを非表示(任意)
連携すると、全てのページにreCAPTCHAのバッジが表示されます。
次のような感じです。
![このブログのPC画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha301.png)
PCの画面
![このブログのスマホ画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha302.png)
スマホの画面
スマホの小さい画面だと少し気になるので、僕は非表示にしました。
![このブログのお問い合わせページ""](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha304.png)
バッジを非表示にする場合は、お問い合わせフォームの送信ボタンの下にreCAPTCHAで保護されていることを明記する必要があります。
reCAPTCHAで保護されていることを明記
This site is protected by reCAPTCHA and the Google
<a href="https://policies.google.com/privacy">Privacy Policy</a> and
<a href="https://policies.google.com/terms">Terms of Service</a> apply.
コードをコピー。
![WordPress Contact Form 7 編集画面](https://qlog.org/wp-content/uploads/2023/06/google-re-captcha305.png)
コンタクトフォームの[submit "送信"]
の下に貼り付けて保存すれば明記されます。
CSSでreCAPTCHAのバッジを非表示
.grecaptcha-badge { visibility: hidden; }
コードをコピー。
CSSファイルに貼り付けてアップロードすれば非表示になります。