The MU forums have moved to

Prevent registration spam from certain emails (6 posts)

  1. modifiedcontent
    Posted 13 years ago #

    I'd like to block all *.info email addresses from registering. That should be possible by hacking this function in wpmu-functions.php:

    function is_email_address_unsafe( $user_email ) {
    	$banned_names = get_site_option( "banned_email_domains" );
    	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 == '' )
    			if (
    				strstr( $email_domain, $banned_domain ) ||
    					strstr( $banned_domain, '/' ) &&
    					preg_match( $banned_domain, $email_domain )
    			return true;
    	return false;

    According to this instruction it's easy:

    Look at is_email_address_unsafe() in wpmu- functions.php - there's a preg_match() there if you have a regex in the list of domains enclosed in "/" characters. For example, /.*\.info/ will match *.info

    But I can't put it together. What am I supposed to put where? Like this?:

    strstr( $banned_domain, '/.*\.info/' )

    What if I want to ban a whole list of domains?

    Apparently the Banned Email List in wpmu admin options does not work because of a bug. Has that been fixed in latest versions? Will it be?

  2. tmoorewp
    Posted 13 years ago #

    The banned email list works just fine to block registration. Have you tried using it or are you just taking that one blog entry as saying it doesn't work?

  3. modifiedcontent
    Posted 13 years ago #

    So darcynorman is wrong?

    Does the Banned Email list accept wildcards, like *.info?

    I'll try it...

  4. kgraeme
    Posted 13 years ago #

    The darcynorman fix was included on the 30th and should be part of the core. However, it is still doing full domains, not wildcards.

  5. modifiedcontent
    Posted 13 years ago #

    Why not wildcards? Full domains is pretty useless as spam fighting method.

  6. andrea_r
    Posted 13 years ago #

    Feel free to code that bit up and submit it to trac then. :)

About this Topic

  • Started 13 years ago by modifiedcontent
  • Latest reply from andrea_r