WordPress.org

WordPress MU

Changeset 825


Ignore:
Timestamp:
12/15/06 11:54:03 (7 years ago)
Author:
donncha
Message:

is_blog_user() is now blog_id aware (Matt)
Move email domain check into it's own function
Another check email on signup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wpmu-functions.php

    r811 r825  
    796796} 
    797797 
    798 function is_blog_user() { 
     798function is_blog_user( $blog_id = 0 ) { 
    799799    global $current_user, $wpdb, $wpmuBaseTablePrefix; 
    800800 
    801     $cap_key = $wpmuBaseTablePrefix . $wpdb->blogid . '_capabilities'; 
     801    if ( !$blog_id ) 
     802        $blog_id = $wpdb->blogid; 
     803 
     804    $cap_key = $wpmuBaseTablePrefix . $blog_id . '_capabilities'; 
    802805 
    803806    if ( is_array($current_user->$cap_key) && in_array(1, $current_user->$cap_key) ) 
     
    825828} 
    826829 
    827 function wpmu_validate_user_signup($user_name, $user_email) { 
    828     global $wpdb, $current_site; 
    829  
    830     $errors = new WP_Error(); 
    831  
    832     $user_name = sanitize_title($user_name); 
    833  
    834     if ( empty( $user_name ) ) 
    835         $errors->add('user_name', __("Please enter a username")); 
    836  
    837     preg_match( "/[a-zA-Z0-9]+/", $user_name, $maybe ); 
    838  
    839     if( $user_name != $maybe[0] ) { 
    840         $errors->add('user_name', __("Only letters and numbers allowed")); 
    841     } 
    842  
    843     $illegal_names = get_site_option( "illegal_names" ); 
    844     if( is_array( $illegal_names ) == false ) { 
    845         $illegal_names = array(  "www", "web", "root", "admin", "main", "invite", "administrator" ); 
    846         add_site_option( "illegal_names", $illegal_names ); 
    847     } 
    848     if( in_array( $user_name, $illegal_names ) == true ) { 
    849         $errors->add('user_name',  __("That username is not allowed")); 
    850     } 
    851  
     830function is_email_address_unsafe( $user_email ) { 
    852831    $banned_names = get_site_option( "banned_email_domains" ); 
    853832    if ( is_array( $banned_names ) && empty( $banned_names ) == false ) { 
     
    861840                ) 
    862841            )  
    863                 $errors->add('user_email',  __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.")); 
    864         } 
    865     } 
     842            return true; 
     843        } 
     844    } 
     845    return false; 
     846} 
     847 
     848function wpmu_validate_user_signup($user_name, $user_email) { 
     849    global $wpdb, $current_site; 
     850 
     851    $errors = new WP_Error(); 
     852 
     853    $user_name = sanitize_title($user_name); 
     854 
     855    if ( empty( $user_name ) ) 
     856        $errors->add('user_name', __("Please enter a username")); 
     857 
     858    preg_match( "/[a-zA-Z0-9]+/", $user_name, $maybe ); 
     859 
     860    if( $user_name != $maybe[0] ) { 
     861        $errors->add('user_name', __("Only letters and numbers allowed")); 
     862    } 
     863 
     864    $illegal_names = get_site_option( "illegal_names" ); 
     865    if( is_array( $illegal_names ) == false ) { 
     866        $illegal_names = array(  "www", "web", "root", "admin", "main", "invite", "administrator" ); 
     867        add_site_option( "illegal_names", $illegal_names ); 
     868    } 
     869    if( in_array( $user_name, $illegal_names ) == true ) { 
     870        $errors->add('user_name',  __("That username is not allowed")); 
     871    } 
     872 
     873    if( is_email_address_unsafe( $user_email ) )  
     874        $errors->add('user_email',  __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.")); 
    866875 
    867876    if( strlen( $user_name ) < 4 ) { 
     
    911920            $errors->add('user_name', __("That username is currently reserved but may be available in a couple of days.")); 
    912921        } 
     922        if( $signup->active == 0 && $signup->user_email == $user_email ) 
     923            $errors->add('user_email_used', __("username and email used")); 
    913924    } 
    914925 
Note: See TracChangeset for help on using the changeset viewer.