I really wish the option to use either reCAPTCHA or hCaptcha was built into wpForo, but since wpForo is hardcoded for Google's reCAPTCHA, it was necessary for me to edit the plugin itself. Below is my recorded account of the process for making this happen.
- Accurate as of wpForo v2.0.2
- WordPress Plugin File Editor was use to make (most of) the edits, because the changes were immediately live on the site and for this situation I did not use a staging area. If you edit the files locally, simply upload them to your server.
- Always backup your files or work on copies. That way if something goes sideways, you can always revert back and try again.
Part 1: REQUIRED TO MAKE IT WORK:
Open:
wpforo\classes\API.php
- Locate (on line 809):
https://www.google.com/recaptcha/api.js
Replace it with:
https://js.hcaptcha.com/1/api.js
- Locate:
g-recaptcha-response
There were two instances: one at line 857 and the other at 859
Replace them both with:h-captcha-response
- Locate on line 859:
https://www.google.com/recaptcha/api/siteverify
Replace it with:
https://hcaptcha.com/siteverify
In wpForo's settings area in the WP dashboard, enter your hCaptcha site key and secret key in the same fields as is done with reCAPTCHA. Then press "Save Options" button.
Now go back to your browser and reload your wpForo login/register page. The hCaptcha function should now be visible and active.
If you don't care that everything still says "reCAPTCHA" within wpForo, then you can stop here as there is nothing more that you need to do to get hCaptcha working. However, if you are OCD challenged like me, proceed on to Part 2.
Part 2: NOT REQUIRED, BUT MAKES IT LOOK CONSISTENT:
Replace ONLY strings. For any search hits you get that are not strings - leave them as is. Do not change them. If you are not sure about a line, don't change it. Look for verbiage such as "Google reCAPTCHA" or "reCAPTCHA".
Search inside these files, I have included code lines for some of them:
wpforo\admin\assets\html\privacy-policy-gdpr.html
Go to lines 72 & 73 and add a line for hCaptcha. I added mine alphabetically, so I moved line 73 down to line 74, and then I added hCaptcha to line 73.
wpforo\admin\assets\xml\english.xml
Update lines 413, 414, 594
wpforo\classes\API.php
Update miscellaneous strings found on lines 862, 871, 874, 957
wpforo\classes\Settings.php
There are various strings scattered within this file. Some are identified below:
- Replace reCAPTCHA image with hCaptcha (line 2297). You can use a link for this if you wish. I used a base64 image to embed it directly within the code. I also colored the image so that it matches with the rest of the wpForo theme.
- Update and reword the descriptions (lines 2298, 2299) then work your way down.
- Replace hCaptcha site link (line 2311)
- Update the reCAPTCHA theme label (lines 2334, 2335)
wpforo\includes\hooks.php
Update strings found on lines 2575, 2602
wpforo\includes\phrases.php
Update strings found on lines 108, 167, 899-900
wpforo\languages\wpforo.pot
(This file is not editable inside WP Plugin File Editor)
Update strings found on lines 4140-4141, 4194, 4199, 4202, 4206, 4215, 4224, 5900, 6154, 8110
I only looked at English language files. If you want an international experience, you will have to edit the language files as well. If you edited any files locally, upload them to your server.
v2.0.5 - Only minor line changes. Otherwise the same.
wpforo/classes/Settings.php
- Update lines 2181, 2182
- Replace "Google reCAPTCHA" lines 2297, 2298
- Replace reCAPTCHA image with hCaptcha (line 2299)
- Update and reword the descriptions (lines 2300, 2301)
- Update Labels (lines 2311, 2312)
- Reword text and replace link with hCaptcha site link (line 2313)
- Update the reCAPTCHA theme label (lines 2336, 2337)
wpforo\includes\hooks.php
- Update string and link found on line 2590
- Update string line 2617