WordPress.org

Make WordPress Core

Changeset 20378


Ignore:
Timestamp:
04/06/2012 07:18:45 PM (7 years ago)
Author:
ryan
Message:

Introduce WP_User::exists(). see #20372

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r20332 r20378  
    743743
    744744    $user = wp_get_current_user();
    745     if ( $user->ID ) {
     745    if ( $user->exists() ) {
    746746        $user_ID = $user->ID;
    747747        $comment_author       = $wpdb->escape($user->display_name);
  • trunk/wp-comments-post.php

    r19712 r20378  
    5555// If the user is logged in
    5656$user = wp_get_current_user();
    57 if ( $user->ID ) {
     57if ( $user->exists() ) {
    5858    if ( empty( $user->display_name ) )
    5959        $user->display_name=$user->user_login;
     
    7474$comment_type = '';
    7575
    76 if ( get_option('require_name_email') && !$user->ID ) {
     76if ( get_option('require_name_email') && !$user->exists() ) {
    7777    if ( 6 > strlen($comment_author_email) || '' == $comment_author )
    7878        wp_die( __('<strong>ERROR</strong>: please fill the required fields (name, email).') );
  • trunk/wp-includes/capabilities.php

    r19712 r20378  
    597597
    598598        $this->data->$key = $value;
     599    }
     600
     601    /**
     602     * Determine whether the user exists in the database.
     603     *
     604     * @since 3.4.0
     605     * @access public
     606     *
     607     * @return bool True if user exists in the database, false if not.
     608     */
     609    function exists() {
     610        return ! empty( $this->ID );
    599611    }
    600612
     
    12601272        $user = new WP_User( $user );
    12611273
    1262     if ( ! $user || ! $user->ID )
     1274    if ( ! $user || ! $user->exists() )
    12631275        return false;
    12641276
     
    13571369        $user = wp_get_current_user();
    13581370
    1359     if ( empty( $user->ID ) )
     1371    if ( ! $user->exists() )
    13601372        return false;
    13611373
  • trunk/wp-includes/comment-template.php

    r19712 r20378  
    15181518    $commenter = wp_get_current_commenter();
    15191519    $user = wp_get_current_user();
    1520     $user_identity = ! empty( $user->ID ) ? $user->display_name : '';
     1520    $user_identity = $user->exists() ? $user->display_name : '';
    15211521
    15221522    $req = get_option( 'require_name_email' );
  • trunk/wp-includes/comment.php

    r20287 r20378  
    580580 */
    581581function wp_set_comment_cookies($comment, $user) {
    582     if ( $user->ID )
     582    if ( $user->exists() )
    583583        return;
    584584
  • trunk/wp-includes/ms-deprecated.php

    r19712 r20378  
    5050    } else {
    5151        $user = get_user_by( 'login', $user_login );
    52         if ( empty( $user->ID ) )
     52        if ( ! $user->exists() )
    5353            return false;
    5454        $user_id = $user->ID;
  • trunk/wp-includes/ms-functions.php

    r20287 r20378  
    186186    $user = new WP_User($user_id);
    187187
    188     if ( empty( $user->ID ) ) {
     188    if ( ! $user->exists() ) {
    189189        restore_current_blog();
    190190        return new WP_Error('user_does_not_exist', __('That user does not exist.'));
     
    248248    // wp_revoke_user($user_id);
    249249    $user = new WP_User($user_id);
    250     if ( empty( $user->ID ) ) {
     250    if ( ! $user->exists() ) {
    251251        restore_current_blog();
    252252        return new WP_Error('user_does_not_exist', __('That user does not exist.'));
  • trunk/wp-includes/pluggable.php

    r20135 r20378  
    710710    $user = wp_get_current_user();
    711711
    712     if ( empty( $user->ID ) )
     712    if ( ! $user->exists() )
    713713        return false;
    714714
  • trunk/wp-includes/user.php

    r20239 r20378  
    260260        $user = new WP_User( $user );
    261261
    262     if ( ! isset( $user->ID ) )
     262    if ( ! $user->exists() )
    263263        return false;
    264264
     
    941941    $user_level = (int) isset($user->user_level) ? $user->user_level : 0;
    942942
    943     if ( 0 == $user->ID ) {
     943    if ( ! $user->exists() ) {
    944944        $user_login = $user_email = $user_url = $user_pass_md5 = $user_identity = '';
    945945        return;
Note: See TracChangeset for help on using the changeset viewer.