Add reCAPTCHA to Contact Form 7 in WordPress
Contact Form 7 is the most popular contact form plugin for WordPress. Combining these two, you can easily create WordPress contact forms with anti-spam protection. In this article, we shall guide you through how to integrate reCAPTCHA to Contact Form 7 in your WordPress website.Note: It is assumed that you have created a Contact Page with Contact Form 7 in WordPress.
Get the reCAPTCHA public and secret keys
To get started with reCAPTCHA, you need a Google account and to register your website for an API key pair. To generate reCaptcha public and secret keys for your domain name, follow the steps mentioned below.
Go to the Google reCaptcha website.
Click the 'Get reCAPTCHA' button as shown in Figure 1.
Enter your website details such as 'Label, Domain and Email Owner(s)' and click on the 'Register' button as shown in Figure 2.
Upon doing so, you can see the generated 'Site Key' and 'Secret Key' as shown in Figure 3.
Copy the key pair into the WordPress Dashboard of the website you registered.
Integrate reCaptcha with Contact Form 7
To integrate reCaptcha with Contact Form 7, follow the steps mentioned below.
Go to the WordPress Dashboard menu 'Contact > Integration' as shown in Figure 4.
Find reCAPTCHA panel and click 'Configure Keys' as shown in Figure 5.
Enter the 'Site Key' and 'Secret Key' into the fields and save them as shown in Figure 6.
Edit the Contact Form
To put a placeholder for a reCAPTCHA widget into your contact form content, follow the steps mentioned below.
Paste the shortcode [recaptcha] to render the reCaptcha field just before the submit button as shown in Figure 7.
Click the 'Save' button as shown in Figure 7.
Preview the contact page. It should look like the one shown in Figure 8.