Posted on 7 Comments

Google’s Invisible Recaptcha with MemberPress Plugin

NOTE: These instructions are no longer valid. Please use MemberPress’ built-in reCaptcha integration instead.

MemberPress has a great Match Captcha add-on included for free which works great for helping to prevent SPAM signups through MemberPress.

But what if you want something that works with more forms/plugins than just MemberPress?

There’s a great, free plugin called Invisible reCaptcha for WordPress that works with many popular plugins out of the box, and is not too hard to integrate with others.

In this post I’ll show you how to get it working with MemberPress.

First you’ll want to install the following two plugins:

  1. Invisible reCaptcha for WordPress
  2. Code Snippets

Next you’ll need to register for Google’s Invisible reCaptcha here:

After registering your site, you’ll be given a Site Key and a Secret Key that you’ll need to copy into the plugin’s settings page like so:

Configure the rest of the Invisible reCaptcha plugin as you wish. You’ll notice there’s no option there for MemberPress. As the plugin doesn’t have support for MemberPress included yet, we’ll need to integrate it ourselves with a little bit of code.

So, copy the following code and paste it into a new Snippet in the Code Snippets plugin.

// Integrates MemberPress with Invisible reCaptcha
function add_invisible_recaptcha_mepr_signup($membership_ID) {
    <div class="mp-form-row mepr_invisible_recaptcha">
      <?php do_action('google_invre_render_widget_action'); ?>
add_action('mepr-checkout-before-submit', 'add_invisible_recaptcha_mepr_signup');
add_action('mepr-login-form-before-submit', 'add_invisible_recaptcha_mepr_signup');
add_action('mepr-forgot-password-form', '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');
add_filter('mepr-validate-login', 'validate_invisible_recaptcha_mepr_signup');
add_filter('mepr-validate-forgot-password', 'validate_invisible_recaptcha_mepr_signup');

It should look something like this:

That’s it! Now you’ll have Invisible reCaptcha on your MemberPress registration forms like this:

7 thoughts on “Google’s Invisible Recaptcha with MemberPress Plugin

  1. How Can I add this in login and forgot password form?


    1. I’ve updated the code based on what I could find. I haven’t tested it just yet so let me know if it works for you or not. Note that I had add_filter instead of add_action in the old code which has been fixed now also.

    2. Great! Now it is working fine. Thanks.

  2. Is it possible to avoid using the Code Snippet plugin and just add that code directly to the functions.php? I’d prefer to not inject php from the dashboard, that just makes me nervous by default.

    1. Yeah, you can put it into functions.php. I don’t recommend it unless you have a child theme, or you know your theme will not be updated.

  3. I followed the instructions and it creates an issue when a user signs up. With this enabled, upon signing up for a paid membership, the payment goes through fine, the user’s account is created, and welcome/admin emails are sent, but it doesn’t log them in correctly or send them to the thank you page. Instead I remain on the purchase page and receive this error:

    ERROR: This email address has already been used. If you are an existing user, please Login to complete your purchase. You will be redirected back here to complete your sign-up afterwards.

    If I log in, everything is fine. But this will obviously confuse any new members and it appears as if it failed. I’ve tried this three times on 2 separate memberships. The problem stops when I disable the Invisible reCaptcha plug-in.

    Any idea why?

    1. Carl, that sounds like you’re trying to make a purchase with an email address that already existed on your site. Try logging in first, or using an email address that doesn’t exist.

Leave a Reply

Your email address will not be published. Required fields are marked *