Membership 2 - BYPASSES Network Limited Email Registrations

I've done a few tests on my network site and found that the membership 2 plugin bypasses wordpress network limited email registration domains. I have a list of 3 allowed domains, when membership 2 is enabled it allows ANY domain to register for the site.

This is a major issue.

  • Vinod Dalvi

    Hi @brettlewis,

    I hope you are well today and thanks for posting on the forum.

    Could you please tell me a bit more in detail what you are referring as " WordPress network limited email registration domains"?

    I have a list of 3 allowed domains, when membership 2 is enabled it allows ANY domain to register for the site.

    Do you mean the three sites in your multisite network?

    Could you please share that domain URLs?

    Have you network activated the membership 2 plugin?

    So do you want to allow users to register only from the main site in your multisite network and not from any other subsites?

    Please advise.

    Kind Regards,
    Vinod Dalvi

    • brettlewis

      What I meant was that "limited email registration" as found in network settings is not being honored by Membership 2 plugin.

      Example. I have limited email registration like so, per domain:
      domain1.com
      domain2.com
      domain3.com

      But a user registers with @yahoo.com and is allowed to register even though they aren't on the allowed list.

      When I disable Membership 2, they get blocked. When I enable Membership 2, they are allowed to register.

      Yes, I have network protect enabled like so:

      /* enable Membership2 network wide */
      define( 'MS_PROTECT_NETWORK', true );
  • Ash

    Hello @brettlewis

    I hope you are well today.

    I can confirm the issue in my test site, so I am marking this as a bug and letting the developer know. Meantime, please use the following code:

    add_filter( 'wpmu_validate_user_signup', 'wpmu_validate_user_signup_cb', 99, 1 );
    function wpmu_validate_user_signup_cb( $arr ) {
        if( is_multisite() ){
            $user_email = $arr['user_email'];
            $errors = $arr['errors'];
            $limited_email_domains = get_site_option( 'limited_email_domains' );
            if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
                $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
                if ( in_array( $emaildomain, $limited_email_domains ) == false )
                    $errors->add( 'user_email', __('Sorry, that email address is not allowed!' ) );
            }
            $arr['errors'] = $errors;
        }
        return $arr;
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.