WordPress.org

Make WordPress Core

Changeset 5627


Ignore:
Timestamp:
06/01/2007 11:13:41 PM (11 years ago)
Author:
rob1n
Message:

phpDoc for wp-includes/registration.php. fixes #4383

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/registration.php

    r5087 r5627  
    11<?php
    22
     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 */
    38function 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 ) ) ) {
    810        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 */
    1422function email_exists( $email ) {
    1523    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 */
    2133function 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 */
    3245function wp_insert_user($userdata) {
    3346    global $wpdb;
     
    131144}
    132145
    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 */
    134152function wp_update_user($userdata) {
    135153    global $wpdb;
     
    165183}
    166184
    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 */
    168194function wp_create_user($username, $password, $email = '') {
    169195    global $wpdb;
     
    177203}
    178204
    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 */
    180213function create_user($username, $password, $email) {
    181214    return wp_create_user($username, $password, $email);
Note: See TracChangeset for help on using the changeset viewer.