The site is under re-construction!

Add google recaptcha to memberpress login page

I’ve come across to a problem for a site i’m following: they use memberpress login page, that unfortunately present a lack about brute force attacks: there is no way to add a google recaptcha so easily.
Since i had to resolve in short this issue, and since i use a simple google recaptcha plugin here at to prevent robot’s fake registrations, i edited the code just a little two lines making it work also into memberpress. The explained trick could be easily done using any other recaptcha plugin, but this 156 lines plugin, can also be easily hacked for our scope and will do the simple dirty job.

Download this plugin and install and configure it (or as you like, may download the plugin, apply modifications as below indicated, then upload into your plugin directory and install):
Simple Google reCAPTCHA

open the file


on it search for this line:

function sgr_check() {

just after add the follow:

if( isset($_REQUEST['mepr_process_login_form']) && isset($_REQUEST['mepr_is_login_page']) ){

then search for:

add_action("init", "sgr_check");

change into:

add_action("init", "sgr_check", 9);

save and replace.

Now open:
and immediately after this:

        <label><input name="rememberme" type="checkbox" id="rememberme" value="forever"<?php checked(isset($_REQUEST['rememberme'])); ?> /> <?php _ex('Remember Me', 'ui', 'memberpress'); ?></label>
      <div class="mp-spacer">&nbsp;</div>

add the follow (note that the code could be added wherever you want, but before the closing </form> tag):

<div class="sgr-recaptcha"></div>

Save and replace. If there is some payment/subscription process using same page to access (for example) a payment renew, then may something else need to be added to prevent action to fire when not needed.

Cheers to all lovely and cool people!


8 responses to “Add google recaptcha to memberpress login page”

  1. Is this possible for the registration page as well?

  2. Hi there! Which registration page? You may refer to
    open it and again just immediately after where:
    <div class="mepr_spacer"> </div>
    <div class="sgr-recaptcha"></div>
    isn’t it?

  3. Should I changed this part for the memberpress registration forms i just want to have the recaptch on the memberpress registration page? –
    if( isset($_REQUEST[‘mepr_process_login_form’]) && isset($_REQUEST[‘mepr_is_login_page’]) ){

    Thank you.

  4. This has been used into a site where the registration flow is done in several pages one after other, where users need to fill forms to register, then if needed (and only if needed, may after a test period) finally pay for a subscription.
    Since the code added was firing also on second step, the payment page, we want to avoid that the recaptcha presents again after first step.
    So the code above, to display the recaptcha only when user fill and submit (is on) the registration form (page), and not if on payment screen for example.
    Yes should work. If not, it is only necessary to change vars to check against and avoid to fire the recaptcha on specified pages/forms.

  5. what do i need to not fire this recaptcha on payment gateway or subscriotion?

  6. Leonard Flier Avatar
    Leonard Flier

    On a simple free registration with no checkout, this code works for me:

    In simple-google-recaptcha.php:

    function sgr_check() {
    //* Modify for MemberPress registration
    if( isset($_REQUEST['mepr_process_signup_form']) ){

    In the MemberPress checkout form:

    Add recaptcha

    I’m not sure what will happen in a site where I’m charging for membership. When I get that far I’ll try to report back.

  7. Hello,
    I’ve tried to follow the instructions you gave, and i can’t find out the sgr_check’s function. I guess it’s not longer in the code of the plugin.
    Is there a way to do the same thing with the actual version of code ? And if yes, how ?
    Thanks you.

  8. Hi guys,

    just let you know that new support topic about this was created here:

    Thanks for your interest!

    Plugin creator

Leave a Reply

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