Support » Plugin: Ban Hammer » Include check for woocommerce

  • Resolved pwallner

    (@pwallner)


    Hi,

    thx for this great plugin, but can you please add the function for checking during registration with woocommerce (means when a new customer want to register).

    I solved the problem, but I think you should include it, so everyone can enjoy it:

    public function init() {
    		...
    		//mcpat
    		add_filter( 'woocommerce_registration_errors', array( &$this, 'banhammer_drop1' ), 10, 3);
    
    	}

    and modified function:

    public function banhammer_drop1($errors, $username, $email ) {
    		if( is_multisite() ) {
    			$the_blacklist = get_site_option( 'banhammer_keys' );
    		} else {
    			$the_blacklist = get_option( 'blacklist_keys' );
    		}
    
    		$blacklist_string = $the_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($email, $blacklist_current) !== false ) {
    				
    				$errors->add( 'invalid_email', __( $this->options['message'] ));
    				if ( $this->options['redirect'] == 'yes' ) {
    					wp_redirect( $this->options['redirect_url'] );
    				} else {
    					return $errors;
    				}
    			}
    		}
            return $errors;
    	}

    Regards
    MCPat

    • This topic was modified 3 years, 8 months ago by pwallner.
  • The topic ‘Include check for woocommerce’ is closed to new replies.