Quick Fix to Ban Spam User Accounts on WPMU

October 30, 2009  | 
6 Comments

Anyone who has maintained a WPMU site lately has more than likely had to contend with spammers worming their way in to create user accounts. Have you noticed that the function to ban email domains in WordPress MU 2.8.4 doesn’t work? You enter the domain in the options for banned email field and they still seem to get through! My biggest offenders lately are from the mail.ru domain. Wicked weasels! Here’s a way to tie their tails together and set them on fire! Much thanks to D’arcy Norman and his helpful post for this very simple fix:

1. Find this file: wp-includes/wpmu-functions.php

2. Locate this function: is_email_address_unsafe() around row 880

3. Turn the string into an array! (see below)

Before:

function before

After:

function is_email_address_unsafe( $user_email ) {
	$banned_names_text = get_site_option( "banned_email_domains" ); // grab the string first
	$banned_names = explode("\n", $banned_names_text); // convert the raw text string to an array with an item per line
	if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {
		$email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
		foreach( (array) $banned_names as $banned_domain ) {
			if( $banned_domain == '' )
				continue;
			if (
				strstr( $email_domain, $banned_domain ) ||
				(
					strstr( $banned_domain, '/' ) &&
					preg_match( $banned_domain, $email_domain )
				)
			)
			return true;
		}
	}
	return false;
}

This is a simple fix in the first two lines of the function, but oh so necessary! I’ve tested it on one of my installs and it works. If you’re maintaining a WPMU site and you’re tired of having to delete fake users, implement this quick fix.

Featured Plugin - Start Your Own Powerful Membership Site

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

Featured Plugin - Open an Online Store with MarketPress

Out of all the WordPress ecommerce plugins available, this has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

Featured Plugin - Every great SEO tweak you need, in one snazzy bundle

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more

Featured Plugin - Start your own Quora / StackOverflow / Yahoo Q&A site

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more

Featured Plugin - WordPress + Google Maps = Perfect

Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more

Featured Plugin - Turn any WordPress page into a fully featured wiki!

To get a wiki up and running you used to need to install Mediawiki and toil away for days configuring it... not any more! This plugin gives you *all* the functionality you want from a wiki, in WordPress!!!
Find out more

Featured Plugin - Easily integrate your WordPress site with Facebook

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

Featured Plugin - Add bottom corner (or anywhere else) chat to your site

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

Featured Plugin - Host sites, get paid, just like WordPress.com

If you've ever wondered how you could offer a paid site management and hosting service, then this is the plugin for you. Offer a freemium or paid service, for any niche you like, it's powered Edublogs.org to success already!
Find out more

6 Responses to Quick Fix to Ban Spam User Accounts on WPMU

  1. Pingback: Your Free blog platform » Blog Archive » Quick Fix to Ban Spam User Accounts on WPMU

  2. This fix was included in the mu 2.8.5.x release.

  3. Excellent. That’s good news.

  4. This was fixed in 2.8.5. but it still doesn’t solve the problem!

  5. Pretty cool post! Some great information to be absorbed in this post. I really like the tips you have given.It’s a very interesting post.Thanks for sharing.Keep posting.

  6. Excellent post!!Thanks a bunch for sharing such useful post with excellent tips with us.. Keep blogging.

Click on a tab to select how you'd like to leave your comment

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting