Created
April 4, 2017 16:19
-
-
Save cartpauj/5a15ec794b301448477138ec8bb71bf9 to your computer and use it in GitHub Desktop.
MemberPress + Invisible Recaptcha plugin integration (untested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Integrates MemberPress with https://wordpress.org/plugins/invisible-recaptcha/ | |
//This is untested code ATM | |
function add_invisible_recaptcha_mepr_signup($membership_ID) { | |
?> | |
<div class="mp-form-row mepr_invisible_recaptcha"> | |
<?php do_action('google_invre_render_widget_action'); ?> | |
</div> | |
<?php | |
} | |
add_filter('mepr-checkout-before-submit', 'add_invisible_recaptcha_mepr_signup'); | |
function validate_invisible_recaptcha_mepr_signup($errors) { | |
$is_valid = apply_filters('google_invre_is_valid_request_filter', true); | |
if(!$is_valid) { | |
$errors[] = "Failed Captcha"; | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'validate_invisible_recaptcha_mepr_signup'); |
To implement the Invisible Recaptcha on the login form you could probably add it to the mepr-login-form-before-submit and mepr-validate-login hooks also?
I see the base plugin hasn't been updated for 4 years. It's crazy that Memberpress have never added a Google ReCaptcha add-on or setting.
I may be forced to try this and use an abandoned plugin. I'll report back on how it went and if it's still working.
@pixelloop MemberPress recommends the Simple Turnstile plugin https://memberpress.com/docs/how-to-prevent-card-testing-and-fraudulent-sign-ups/
Ah, thanks, that's good to know. I missed that.
I may give that a try instead of ReCaptcha v3 and see if it solves my client's issue.
I appreciate you getting back to me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great, thanks! Can you add the Login and Forgot Password forms too? That would be awesome.
@Dutcch if you are using a child theme, just add this code to the end of it's functions.php . If you have activated Invisible Recaptcha in your WP you don't have to do anything else.