Changeset 5627 for trunk/wp-includes/registration.php
- Timestamp:
- 06/01/2007 11:13:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/registration.php
r5087 r5627 1 1 <?php 2 2 3 /** 4 * Checks whether the given username exists. 5 * @param string $username Username. 6 * @return mixed The user's ID on success, and null on failure. 7 */ 3 8 function username_exists( $username ) { 4 global $wpdb; 5 $username = sanitize_user( $username ); 6 $user = get_userdatabylogin($username); 7 if ( $user ) 9 if ( $user = get_userdatabylogin( sanitize_user( $username ) ) ) { 8 10 return $user->ID; 9 10 return null; 11 } 12 13 11 } else { 12 return null; 13 } 14 } 15 16 /** 17 * Checks whether the given email exists. 18 * @global object $wpdb WordPress database layer. 19 * @param string $email Email. 20 * @return mixed The user's ID on success, and false on failure. 21 */ 14 22 function email_exists( $email ) { 15 23 global $wpdb; 16 $email = addslashes( $email ); 17 return $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '$email'"); 18 } 19 20 24 $email = $wpdb->escape( $email ); 25 return $wpdb->get_var( "SELECT ID FROM $wpdb->users WHERE user_email = '$email'" ); 26 } 27 28 /** 29 * Checks whether an username is valid. 30 * @param string $username Username. 31 * @return bool A filtered boolean. 32 */ 21 33 function validate_username( $username ) { 22 $name = sanitize_user($username, true); 23 $valid = true; 24 25 if ( $name != $username ) 26 $valid = false; 27 28 return apply_filters('validate_username', $valid, $username); 29 } 30 31 34 $sanitized = sanitize_user( $username, true ); 35 $valid = ( $sanitized == $username ); 36 return apply_filters( 'validate_username', $valid, $username ); 37 } 38 39 /** 40 * Insert an user into the database. 41 * @global object $wpdb WordPress database layer. 42 * @param array $userdata An array of user data. 43 * @return int The newly created user's ID. 44 */ 32 45 function wp_insert_user($userdata) { 33 46 global $wpdb; … … 131 144 } 132 145 133 146 /** 147 * Update an user in the database. 148 * @global object $wpdb WordPress database layer. 149 * @param array $userdata An array of user data. 150 * @return int The updated user's ID. 151 */ 134 152 function wp_update_user($userdata) { 135 153 global $wpdb; … … 165 183 } 166 184 167 185 /** 186 * A simpler way of inserting an user into the database. 187 * See also: wp_insert_user(). 188 * @global object $wpdb WordPress database layer. 189 * @param string $username The user's username. 190 * @param string $password The user's password. 191 * @param string $email The user's email (optional). 192 * @return int The new user's ID. 193 */ 168 194 function wp_create_user($username, $password, $email = '') { 169 195 global $wpdb; … … 177 203 } 178 204 179 205 /** 206 * An alias of wp_create_user(). 207 * @param string $username The user's username. 208 * @param string $password The user's password. 209 * @param string $email The user's email (optional). 210 * @return int The new user's ID. 211 * @deprecated 212 */ 180 213 function create_user($username, $password, $email) { 181 214 return wp_create_user($username, $password, $email);
Note: See TracChangeset
for help on using the changeset viewer.