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. Since we are not allowed to edit past posts on this site, below is my freshly recorded account of the process for modding this WP plugin.
-
Accurate as of wpForo v2.1.1
-
WordPress Plugin File Editor can be used to make (most of) the edits, or you can edit the files locally. 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 822):
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 870 and the other at 872
Replace them both with:h-captcha-response
-
Locate on line 872 (same line as above):
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
Open the above file and go to lines 72 & 73 and add a line for hCaptcha (see code box below). I added mine alphabetically, so I moved line 73 down to line 74, and then I added hCaptcha to line 73.
<li>hCaptcha (by Intuition Machines, Inc) - Does not treat visitors as the product, as is done with ad networks such as Google. They only care whether a visit is good or bad. hCaptcha complies with GDPR, CCPA, LGPD, PIPL, and other global data laws. hCaptcha Privacy Policy: <a href="https://www.hcaptcha.com/privacy" target="_blank" rel="noopener noreferrer"> https://www.hcaptcha.com/privacy</a></li>
The code above is what I entered. Use that or write your own.
wpforo\admin\assets\xml\english.xml
-
Lines 413, 414: Change “Google reCAPTCHA” to “hCaptcha”.
-
Line 594: Change “Google reCAPTCHA” to “hCaptcha”.
Also correct grammar.
wpforo\classes\API.php
Change “Google reCAPTCHA” or “reCAPTCHA” to “hCaptcha”.
Update strings found on lines 875, 884, 887 (correct grammar), 970
wpforo\classes\Settings.php
There are various strings within the above file. The lines I changed are listed below:
RECAPTCHA
-
Line 2221 “description”: Reword the description to reflect hCaptcha.
-
Line 2222 “description_original”: Same as above.
-
Line 2337 “title”: Change “Google reCAPTCHA” to “hCaptcha”
-
Line 2338 “title_original”: Same as above.
-
Line 2339 “icon”: Replace reCAPTCHA image with hCaptcha. Replace everything inside the single quote pair (‘). 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.
-
Line 2340 “description”: Reword the description to reflect hCaptcha.
-
Line 2341 “description_original”: Same as above.
RECAPTCHA / OPTIONS
-
Lines 2351, 2352, 2353, 2354: Replace “reCAPTCHA” with “hCaptcha” and remove the text “version 2, “
-
Line 2353 “description”: At a minimum, replace Google’s site link with the hCaptcha site link (found in the box below). However, for better presentation, I reworded and added extra formatting. The ENTIRE line of code is in the box below. Copy just what you need, or use the whole thing.
"description" => __( 'To start using hCaptcha, it will be necessary to aquire an API key pair. ', 'wpforo' ) . '<br>' . 'Signup for free, register your site and get your API keys ' . '<a href="https://hCaptcha.com/?r=8bfdc061fc0a" target="_blank">' . __( 'Register your site and get API keys here', 'wpforo' ) . '</a>.',
RECAPTCHA / OPTIONS / THEME
-
Line 2376 “label”: Change “reCAPTCHA” to “hCaptcha”.
-
Line 2377 “label_original”: Same as above.
wpforo\includes\hooks.php
-
Line 2655: Change Google's site link to hCaptcha’s site link:
https://hCaptcha.com/?r=8bfdc061fc0a
Also change “Google reCAPTCHA” to “hCaptcha”. -
Line 2682: Change “Google reCAPTCHA” to “hCaptcha”.
wpforo\includes\phrases.php
-
Line 108: Change “Google reCAPTCHA” to “hCaptcha”.
Also correct improper grammar present in the string. -
Lines 167, 899-900: Change “Google reCAPTCHA” to “hCaptcha”.
wpforo\languages\wpforo.pot
(This file is not editable inside the WP Plugin File Editor)
-
Lines 4220-4221: Change “Google reCAPTCHA” to “hCaptcha”.
Also correct grammar, but keep each line of text near the same length as the original. -
Line 4274: Change “Google reCAPTCHA” to “hCaptcha”.
-
Line 4279: Change “reCAPTCHA” to “hCaptcha”.
-
Line 4282: Change “reCAPTCHA version 2” to “hCaptcha”.
-
Lines 4286, 4295, 4304: Change “reCAPTCHA” to “hCaptcha”.
-
Line 5998: Change “Google reCAPTCHA” to “hCaptcha”.
Also correct grammar. -
Lines 6256, 8212: Change “Google reCAPTCHA” to “hCaptcha”.
I only looked at English language files. If you want an international experience, you will have to edit those language files as well. If you edited any files locally, upload them to your server.
You can follow the instructions above to have the hands on experience, or if don’t have the patience for that, you can download and install the hCaptcha modded version that I used on my own site after going through the above steps.
wpForo v2.1.1 – hCaptcha Mod
https://www.mediafire.com/file/u8ze4it1tjnrs4n/wpforo.2.1.1-hCap_mod.zip/file
SHA-256: CA02D6084169DB7AC31C439CA4B33200ABC6D5A5BF9932F3CEB754CCACE3B0CA
wpForo v2.1.4 – hCaptcha Mod
https://www.mediafire.com/file/audaorsj067voyh/wpforo.2.1.4-hCap_mod.zip/file
SHA-256: 5DDF1F1329958F47D0346A50EC812AA053A498D38D8F12DC20870C1898B8DF5D
There were line changes with this release.
wpForo v2.1.5 – hCaptcha Mod
https://www.mediafire.com/file/v8qoi2rn2z77efx/wpforo.2.1.5-hCap_mod.zip/file
SHA-256: BDA5192926170B3E988C08AD7B49F3CE44D118933C0C34FAB526B5BC783AA014
Sumfile: https://www.mediafire.com/file/ssm8dflv705uboa/wpforo.2.1.5-hCap_mod.zip.sha256/file