Add Google reCAPTCHA to WordPress comments without plugin

reCAPTCHA it’s a free anti-spam service offered by Google. Easy to use, effective, easy to implement it’s the most used captcha API. You can read more at https://www.google.com/recaptcha/intro/. Let’s add Google reCAPTCHA to WordPress comments and see how it works.

Is there any way to attach reCAPTCHA to my contact form as well? I can’t find in your code how you append the reCAPTCHA div to the submit button or elsewhere. But I’d like to protect my contact form via your method. Please, answer me asap. Thank you very much!

Hi,
I’m almost there (I think). How do I get this on the login page? I’m using the login_form filter and action hooks by adding them to the ‘login_form’ but when I add those below the comment form in the functions.php it looks like this.

Thanks for this great tutorial but I have some problem please check this link for the screenshot https://i.imgur.com/A2BTcXF.png I want to move this box down in the button as this captcha is hiding my text

I created a test Page and it’s working.
You should check if your page loaded reCAPTCHA.
Search for recaptcha/api.js and <div class=”g-recaptcha”.
And also you could check in Developer Tools from Chrome or Firefox if you have errors.

I really like the approach and would love to implement this in a page but can’t seem to find the right hooks. Could you perhaps help? I don’t want to enable comments on all pages. What hooks should I be looking at and is it possible to enable it on a single page (and not others)?

Sorry, it won’t work for me. I’ve placed the code in the appropriate place (top) in “singles.php”, placed the code and the 2 keys in their respective places in “functions.php” but, no go. I can’t even see it! Before I tried your code, I tried it with a Google reCaptcha plugin which kept giving me an error and wouldn’t let me sign in. Deactivating it solved the problem. I have changed keys 3 times and I don’t know what else to do. Think you can help me?

Rechecked, it seems the problem is the login (at least), where it’s not showing up. I can see it in the comments but only because, although I appear as loged in, as soon as I try to navigate within the site, I am loged out. Very strange!

Ok, I think I’ve understood the problem. The thing is that I have the “Ultimate Member” plugin installed which has its own login and registration pages. The code you are so kindly sharing, obviously does not include these pages. From reading around (I,m a newby, if you haven’t noticed :), I think what I need to do is to add hooks to those pages, which I know I don’t know how to do.

I have for the moment, implemented the plugin’s extension but I don’t like it as it isn’t v2 or v3 and gives that awfull image thingy which I personally, have always despised. It’ll have to do for the moment, however. So, I’ll keep searching and learning and if you can give me a hand, I’d deeply appreciate it. Cheers!