WordPress.org

Make WordPress Core

Ticket #4383: registration.phpdoc.r6542.diff

File registration.phpdoc.r6542.diff, 5.6 KB (added by darkdragon, 7 years ago)

Adds @since information to the functions and adds more details to the files. Based on r6542.

  • registration.php

     
    11<?php 
     2/** 
     3 * User Registration API 
     4 * 
     5 * @package WordPress 
     6 */ 
    27 
    38/** 
    4  * Checks whether the given username exists. 
     9 * username_exists() - Checks whether the given username exists. 
     10 * 
     11 * @since 2.0.0 
     12 * 
    513 * @param string $username Username. 
    6  * @return mixed The user's ID on success, and null on failure. 
     14 * @return null|int The user's ID on success, and null on failure. 
    715 */ 
    816function username_exists( $username ) { 
    917        if ( $user = get_userdatabylogin( $username ) ) { 
     
    1422} 
    1523 
    1624/** 
    17  * Checks whether the given email exists. 
    18  * @global object $wpdb WordPress database layer. 
     25 * email_exists() - Checks whether the given email exists. 
     26 * 
     27 * @since 2.1.0 
     28 * @uses $wpdb 
     29 * 
    1930 * @param string $email Email. 
    20  * @return mixed The user's ID on success, and false on failure. 
     31 * @return bool|int The user's ID on success, and false on failure. 
    2132 */ 
    2233function email_exists( $email ) { 
    2334        if ( $user = get_user_by_email($email) ) 
     
    2738} 
    2839 
    2940/** 
    30  * Checks whether an username is valid. 
     41 * validate_username() - Checks whether an username is valid. 
     42 * 
     43 * @since 2.0.1 
     44 * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters 
     45 * 
    3146 * @param string $username Username. 
    32  * @return bool A filtered boolean. 
     47 * @return bool Whether username given is valid 
    3348 */ 
    3449function validate_username( $username ) { 
    3550        $sanitized = sanitize_user( $username, true ); 
     
    3853} 
    3954 
    4055/** 
    41  * Insert an user into the database. 
    42  * @global object $wpdb WordPress database layer. 
     56 * wp_insert_user() - Insert an user into the database. 
     57 * 
     58 * Can update a current user or insert a new user based on whether 
     59 * the user's ID is present. 
     60 * 
     61 * Can be used to update the user's info (see below), set the user's 
     62 * role, and set the user's preference on whether they want the rich 
     63 * editor on. 
     64 * 
     65 * Most of the $userdata array fields have filters associated with 
     66 * the values. The exceptions are 'rich_editing', 'role', 'jabber', 
     67 * 'aim', 'yim', 'user_registered', and 'ID'. The filters have the 
     68 * prefix 'pre_user_' followed by the field name. An example using 
     69 * 'description' would have the filter called, 'pre_user_description' 
     70 * that can be hooked into. 
     71 * 
     72 * The $userdata array can contain the following fields: 
     73 * 'ID' - An integer that will be used for updating an existing user. 
     74 * 'user_pass' - A string that contains the plain text password for the user. 
     75 * 'user_login' - A string that contains the user's username for logging in. 
     76 * 'user_nicename' - A string that contains a nicer looking name for the user. 
     77 *              The default is the user's username. 
     78 * 'user_url' - A string containing the user's URL for the user's web site. 
     79 * 'user_email' - A string containing the user's email address. 
     80 * 'display_name' - A string that will be shown on the site. Defaults to user's username. 
     81 *              It is likely that you will want to change this, for both appearance and security 
     82 *              through obscurity (that is if you don't use and delete the default 'admin' user). 
     83 * 'nickname' - The user's nickname, defaults to the user's username. 
     84 * 'first_name' - The user's first name. 
     85 * 'last_name' - The user's last name. 
     86 * 'description' - A string containing content about the user. 
     87 * 'rich_editing' - A string for whether to enable the rich editor or not. False if not 
     88 *              empty. 
     89 * 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'. 
     90 * 'role' - A string used to set the user's role. 
     91 * 'jabber' - User's Jabber account. 
     92 * 'aim' - User's AOL IM account. 
     93 * 'yim' - User's Yahoo IM account. 
     94 * 
     95 * @since 2.0.0 
     96 * @uses $wpdb WordPress database layer. 
     97 * @uses apply_filters() Calls filters for most of the $userdata fields with the prefix 'pre_user'. See note above. 
     98 * @uses do_action() Calls 'profile_update' hook when updating giving the user's ID 
     99 * @uses do_action() Calls 'user_register' hook when creating a new user giving the user's ID 
     100 * 
    43101 * @param array $userdata An array of user data. 
    44102 * @return int The newly created user's ID. 
    45103 */ 
     
    140198} 
    141199 
    142200/** 
    143  * Update an user in the database. 
     201 * wp_update_user() - Update an user in the database 
     202 * 
     203 * It is possible to update a user's password by specifying the 
     204 * 'user_pass' value in the $userdata parameter array. 
     205 * 
     206 * If $userdata does not contain an 'ID' key, then a new user 
     207 * will be created and the new user's ID will be returned. 
     208 * 
     209 * If current user's password is being updated, then the cookies 
     210 * will be cleared. 
     211 * 
     212 * @since 2.0.0 
     213 * @see wp_insert_user() For what fields can be set in $userdata 
     214 * @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already 
     215 * 
    144216 * @param array $userdata An array of user data. 
    145217 * @return int The updated user's ID. 
    146218 */ 
     
    176248} 
    177249 
    178250/** 
    179  * A simpler way of inserting an user into the database. 
    180  * @see wp_insert_user(). 
    181  * @global object $wpdb WordPress database layer. 
     251 * wp_create_user() - A simpler way of inserting an user into the database. 
     252 * 
     253 * Creates a new user with just the username, password, and email. For a more 
     254 * detail creation of a user, use wp_insert_user() to specify more infomation. 
     255 * 
     256 * @since 2.0.0 
     257 * @see wp_insert_user() More complete way to create a new user 
     258 * @uses $wpdb Escapes $username and $email parameters 
     259 * 
    182260 * @param string $username The user's username. 
    183261 * @param string $password The user's password. 
    184262 * @param string $email The user's email (optional).