Changeset 6269
- Timestamp:
- 08/29/2012 06:47:11 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
bp-members/bp-members-functions.php (modified) (1 diff)
-
bp-settings/bp-settings-actions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-functions.php
r6259 r6269 971 971 972 972 /** 973 * Check that an email address is valid for use 974 * 975 * Performs the following checks: 976 * - Is the email address well-formed? 977 * - Is the email address already used? 978 * - If there's an email domain blacklist, is the current domain on it? 979 * - If there's an email domain whitelest, is the current domain on it? 980 * 981 * @since 1.6.2 982 * 983 * @param string $user_email The email being checked 984 * @return bool|array True if the address passes all checks; otherwise an array 985 * of error codes 986 */ 987 function bp_core_validate_email_address( $user_email ) { 988 $errors = array(); 989 990 $user_email = sanitize_email( $user_email ); 991 992 // Is the email well-formed? 993 if ( ! is_email( $user_email ) ) 994 $errors['invalid'] = 1; 995 996 // Is the email on the Banned Email Domains list? 997 // Note: This check only works on Multisite 998 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) ) 999 $errors['domain_banned'] = 1; 1000 1001 // Is the email on the Limited Email Domains list? 1002 // Note: This check only works on Multisite 1003 $limited_email_domains = get_site_option( 'limited_email_domains' ); 1004 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 1005 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 1006 if ( ! in_array( $emaildomain, $limited_email_domains ) ) { 1007 $errors['domain_not_allowed'] = 1; 1008 } 1009 } 1010 1011 // Is the email alreday in use? 1012 if ( email_exists( $user_email ) ) 1013 $errors['in_use'] = 1; 1014 1015 $retval = ! empty( $errors ) ? $errors : true; 1016 1017 return $retval; 1018 } 1019 1020 /** 973 1021 * Validate a user name and email address when creating a new user. 1022 * 1023 * @todo Refactor to use bp_core_validate_email_address() 974 1024 * 975 1025 * @param string $user_name Username to validate -
trunk/bp-settings/bp-settings-actions.php
r6183 r6269 72 72 if ( $bp->displayed_user->userdata->user_email != $user_email ) { 73 73 74 // Is email valid 75 if ( !is_email( $user_email ) ) 76 $email_error = 'invalid'; 77 78 // Get blocked email domains 79 $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' ); 80 81 // If blocked email domains exist, see if this is one of them 82 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 83 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 84 85 if ( in_array( $emaildomain, (array) $limited_email_domains ) == false ) { 74 // Run some tests on the email address 75 $email_checks = bp_core_validate_email_address( $user_email ); 76 77 if ( true !== $email_checks ) { 78 if ( isset( $email_checks['invalid'] ) ) { 79 $email_error = 'invalid'; 80 } 81 82 if ( isset( $email_checks['domain_banned'] ) || isset( $email_checks['domain_not_allowed'] ) ) { 86 83 $email_error = 'blocked'; 87 84 } 88 } 89 90 // No errors, and email address doesn't match 91 if ( ( false === $email_error ) && email_exists( $user_email ) ) { 92 $email_error = 'taken'; 85 86 if ( isset( $email_checks['in_use'] ) ) { 87 $email_error = 'taken'; 88 } 93 89 } 94 90
Note: See TracChangeset
for help on using the changeset viewer.