Changeset 6336
- Timestamp:
- 09/16/2012 03:29:15 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-functions.php
r6314 r6336 1039 1039 1040 1040 /** 1041 * Add the appropriate errors to a WP_Error object, given results of a validation test 1042 * 1043 * Functions like bp_core_validate_email_address() return a structured array 1044 * of error codes. bp_core_add_validation_error_messages() takes this array and 1045 * parses, adding the appropriate error messages to the WP_Error object. 1046 * 1047 * @since BuddyPress (1.7) 1048 * @see bp_core_validate_email_address() 1049 * 1050 * @param obj $errors WP_Error object 1051 * @param array $validation_results The return value of a validation function 1052 * like bp_core_validate_email_address() 1053 */ 1054 function bp_core_add_validation_error_messages( WP_Error $errors, $validation_results ) { 1055 if ( ! empty( $validation_results['invalid'] ) ) 1056 $errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) ); 1057 1058 if ( ! empty( $validation_results['domain_banned'] ) ) 1059 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) ); 1060 1061 if ( ! empty( $validation_results['domain_not_allowed'] ) ) 1062 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) ); 1063 1064 if ( ! empty( $validation_results['in_use'] ) ) 1065 $errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) ); 1066 } 1067 1068 /** 1041 1069 * Validate a user name and email address when creating a new user. 1042 *1043 * @todo Refactor to use bp_core_validate_email_address()1044 1070 * 1045 1071 * @param string $user_name Username to validate … … 1050 1076 1051 1077 $errors = new WP_Error(); 1052 $user_email = sanitize_email( $user_email );1053 1078 1054 1079 // Apply any user_login filters added by BP or other plugins before validating … … 1079 1104 $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!', 'buddypress' ) ); 1080 1105 1081 if ( !is_email( $user_email ) )1082 $errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) );1083 1084 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) )1085 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );1086 1087 $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' );1088 1089 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {1090 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );1091 1092 if ( in_array( $emaildomain, (array) $limited_email_domains ) == false )1093 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );1094 }1095 1096 1106 // Check if the username has been used already. 1097 1107 if ( username_exists( $user_name ) ) 1098 1108 $errors->add( 'user_name', __( 'Sorry, that username already exists!', 'buddypress' ) ); 1099 1109 1100 // Check if the email address has been used already. 1101 if ( email_exists( $user_email ) ) 1102 $errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) ); 1103 1110 // Validate the email address and process the validation results into 1111 // error messages 1112 $validate_email = bp_core_validate_email_address( $user_email ); 1113 bp_core_add_validation_error_messages( $errors, $validate_email ); 1114 1115 // Assemble the return array 1104 1116 $result = array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ); 1105 1117
Note: See TracChangeset
for help on using the changeset viewer.