diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
commit | 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 (patch) | |
tree | 2a06e5261263c68d8afd95a6328879dc289cb909 /wp-includes/registration.php | |
parent | b83c34a7010faee0223f6037025c350da12e05e6 (diff) | |
download | wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.gz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.xz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.zip |
Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/registration.php')
-rw-r--r-- | wp-includes/registration.php | 75 |
1 files changed, 54 insertions, 21 deletions
diff --git a/wp-includes/registration.php b/wp-includes/registration.php index cd387fd..c5b0fb1 100644 --- a/wp-includes/registration.php +++ b/wp-includes/registration.php @@ -1,34 +1,47 @@ <?php +/** + * Checks whether the given username exists. + * @param string $username Username. + * @return mixed The user's ID on success, and null on failure. + */ function username_exists( $username ) { - global $wpdb; - $username = sanitize_user( $username ); - $user = get_userdatabylogin($username); - if ( $user ) + if ( $user = get_userdatabylogin( sanitize_user( $username ) ) ) { return $user->ID; - - return null; + } else { + return null; + } } - +/** + * Checks whether the given email exists. + * @global object $wpdb WordPress database layer. + * @param string $email Email. + * @return mixed The user's ID on success, and false on failure. + */ function email_exists( $email ) { global $wpdb; - $email = addslashes( $email ); - return $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '$email'"); + $email = $wpdb->escape( $email ); + return $wpdb->get_var( "SELECT ID FROM $wpdb->users WHERE user_email = '$email'" ); } - +/** + * Checks whether an username is valid. + * @param string $username Username. + * @return bool A filtered boolean. + */ function validate_username( $username ) { - $name = sanitize_user($username, true); - $valid = true; - - if ( $name != $username ) - $valid = false; - - return apply_filters('validate_username', $valid, $username); + $sanitized = sanitize_user( $username, true ); + $valid = ( $sanitized == $username ); + return apply_filters( 'validate_username', $valid, $username ); } - +/** + * Insert an user into the database. + * @global object $wpdb WordPress database layer. + * @param array $userdata An array of user data. + * @return int The newly created user's ID. + */ function wp_insert_user($userdata) { global $wpdb; @@ -130,7 +143,12 @@ function wp_insert_user($userdata) { return $user_id; } - +/** + * Update an user in the database. + * @global object $wpdb WordPress database layer. + * @param array $userdata An array of user data. + * @return int The updated user's ID. + */ function wp_update_user($userdata) { global $wpdb; @@ -164,7 +182,15 @@ function wp_update_user($userdata) { return $user_id; } - +/** + * A simpler way of inserting an user into the database. + * See also: wp_insert_user(). + * @global object $wpdb WordPress database layer. + * @param string $username The user's username. + * @param string $password The user's password. + * @param string $email The user's email (optional). + * @return int The new user's ID. + */ function wp_create_user($username, $password, $email = '') { global $wpdb; @@ -176,7 +202,14 @@ function wp_create_user($username, $password, $email = '') { return wp_insert_user($userdata); } - +/** + * An alias of wp_create_user(). + * @param string $username The user's username. + * @param string $password The user's password. + * @param string $email The user's email (optional). + * @return int The new user's ID. + * @deprecated + */ function create_user($username, $password, $email) { return wp_create_user($username, $password, $email); } |