#17894 closed defect (bug) (fixed)
WP_User class uses ID as username when $id = null
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.3 | Priority: | normal |
Severity: | normal | Version: | 3.1.3 |
Component: | General | Keywords: | has-patch 3.3-early |
Focuses: | Cc: |
Description
WP_User's __construct()
function has:
if ( ! is_numeric( $id ) ) { $name = $id; $id = 0; }
presumably for when people incorrectly pass the username as the ID. However, this also returns true when the ID is set as null and is used as the username.
Code to reproduce:
add_action( 'admin_init', 'display_admin_user' ); function display_admin_user() { $user_by_name = new WP_User( null, 'admin' ); $user_by_id = new WP_User( 1 ); echo '<p>' . print_r( $user_by_name, true ) . '</p>'; echo '<p>' . print_r( $user_by_id, true ) . '</p>'; }
Attachments (2)
Change History (6)
Note: See
TracTickets for help on using
tickets.
! empty( $id )