• Resolved ddagva

    (@ddagva)


    We’d like to use this plugin on our membership site to prevent duplicate registrations (ie using known disposable e-mail servers).

    But the membership plugin we’re using seems to conflict with Ban Hammer, probably because it uses its own registration form and logics.

    The membership plugin developers stated that “they would be happy to work with [you] to make the two compatible”.

    So, here I am, kindly asking if you would be interested in such a collaboration?
    Thank you in advance.

    PS: I don’t know if this is the right place to post this request, sorry if it’s not but I couldn’t find any other mean to get in touch with you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    This was fine ??

    Sadly, I don’t have much free time at the moment but I’d be interested to see why it’s not working. In general, I don’t really extend this past the ‘normal’ WP signup flow and BuddyPress, but of course if there’s a specific filter I can hook into for this to work, I’m game.

    If they want to open up an issue at https://github.com/ipstenu/ban-hammer for tracking and code chatter, that would be perfect for me ??

    Thread Starter ddagva

    (@ddagva)

    Thanks!

    I forward this to the plugin developers, and let them get directly in touch with you.

    
    function validate_mepr_signup_via_banhammer($errors) {
      if( !class_exists('MeprOptions') ||
          !class_exists('BanHammer') ||
          !is_email($_POST['user_email']) ) {
        return $errors;
      }
    
      if(banhammer_mepr_bademail(stripslashes($_POST['user_email']))) {
        $errors[] = "You've been spam blasted!";
      }
    
      return $errors;
    }
    add_action('mepr-validate-signup', 'validate_mepr_signup_via_banhammer');
    
    function banhammer_mepr_bademail($user_email) {
      if(is_multisite()) {
        $banhammer_blacklist = get_site_option('banhammer_keys');
      }
      else {
        $banhammer_blacklist = get_option('blacklist_keys');
      }
    
      // Get blacklist
      $blacklist_string = $banhammer_blacklist;
      $blacklist_array  = explode("\n", $blacklist_string);
      $blacklist_size   = sizeof($blacklist_array);
    
      // Go through blacklist
      for($i = 0; $i < $blacklist_size; $i++) {
        $blacklist_current = trim($blacklist_array[$i]);
    
        if(stripos($user_email, $blacklist_current) !== false) {
          return true;
        }
      }
      
      return false;
    }
    
    Thread Starter ddagva

    (@ddagva)

    Thanks a lot for supplying this code!

    Problem solved.

    Gratefully yours

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    So as it happens, I was working on this in order to make things more sustainable.

    The BETA version (2.6) can be downloaded via GitHub: https://github.com/ipstenu/ban-hammer/tree/REL_2.6

    What it does is allows BuddyPress and Multisite to use the normal check (so it doesn’t have it’s own weird one) by properly calling the function and reporting back errors:

    So instead of reproducing all that code, you can use a filter. Without using the plugin, and just looking at the code you provided, I believe this would be all you need:

    	
    function validate_mepr_signup_via_banhammer( $errors ) {
    
      if( 
            class_exists('MeprOptions') && 
            class_exists('BanHammer') && 
            is_email($_POST['user_email']) && 
            (new BanHammer)->banhammer_drop( $_POST['user_name'] , $_POST['user_email']), $errors[] ) 
        )
            $errors[] = (new BanHammer)->options['message'];
    
        return $errors;
    }

    That code will only working PHP 5.4 and up. See https://stackoverflow.com/a/19694064 if you need support for older, as you’ll have to change (new BanHammer)->

    I may be wrong with the $errors bit but here’s the code that I’m using now: https://github.com/Ipstenu/ban-hammer/blob/REL_2.6/ban-hammer.php#L481-L485

    Much less to have to support!

    Looks great, thanks @ipstenu !

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Compatibility with a membership plugin’ is closed to new replies.