WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19595 closed defect (bug) (fixed)

$userdata not populated properly

Reported by: scribu Owned by: ryan
Milestone: 3.3.1 Priority: normal
Severity: normal Version: 3.3
Component: Users Keywords: has-patch
Focuses: Cc:

Description

Example code (from a theme file):

global $userdata;
get_currentuserinfo(); // grabs the user info and puts into vars

print_r($userdata);

In WP 3.2:

stdClass Object
(
    [ID] => 1
    [user_login] => admin
    [user_pass] => $P$B2RBgdoaBDn7zWc/55YCMV3rI2ga7n/
    [user_nicename] => admin
    [user_email] => a@b.com
    [user_url] => 
    [user_registered] => 2011-10-26 14:21:09
    [user_activation_key] => 
    [user_status] => 0
    [display_name] => admin
    [spam] => 0
    [deleted] => 0
    [first_name] => 
    [last_name] => 
    [nickname] => admin
    [description] => 
    [rich_editing] => true
    [comment_shortcuts] => false
    [admin_color] => fresh
    [use_ssl] => 0
    [show_admin_bar_front] => true
    [aim] => 
    [yim] => 
    [jabber] => 
    [wp_capabilities] => Array
        (
            [administrator] => 1
        )

    [wp_user_level] => 10
    [wp_dashboard_quick_press_last_post_id] => 3
    [wp_usersettings] => mfold=f&editor=tinymce
    [wp_usersettingstime] => 1322620386
    [source_domain] => appthemes.dev
    [primary_blog] => 1
    [wp_2_capabilities] => Array
        (
            [administrator] => 1
        )

    [wp_2_user_level] => 10
    [wp_2_usersettings] => mfold=f&editor=tinymce
    [wp_2_usersettingstime] => 1322434749
    [wp_2_dashboard_quick_press_last_post_id] => 185
    [wp_3_capabilities] => Array
        (
            [administrator] => 1
        )

    [wp_3_user_level] => 10
    [wp_3_usersettings] => mfold=f&editor=tinymce
    [wp_3_usersettingstime] => 1322842998
    [wp_3_dashboard_quick_press_last_post_id] => 129
    [_last_activity] => 2011-11-22 15:48:55
    [dismissed_wp_pointers] => wp330_toolbar,wp330_media_uploader
    [managenavmenuscolumnshidden] => Array
        (
            [0] => link-target
            [1] => css-classes
            [2] => xfn
            [3] => description
        )

    [metaboxhidden_navmenus] => Array
        (
            [0] => add-post
            [1] => add-post_tag
            [2] => add-listing_categories
            [3] => add-listing_tag
        )

    [nav_menu_recently_edited] => 12
    [wp_4_capabilities] => Array
        (
            [administrator] => 1
        )

    [wp_4_user_level] => 10
    [wp_4_usersettings] => mfold=f&editor=tinymce
    [wp_4_usersettingstime] => 1323134812
    [wp_4_dashboard_quick_press_last_post_id] => 15
    [wp_5_capabilities] => Array
        (
            [administrator] => 1
        )

    [wp_5_user_level] => 10
    [wp_5_usersettings] => mfold=f&editor=tinymce
    [wp_5_usersettingstime] => 1323383130
    [wp_5_dashboard_quick_press_last_post_id] => 15
    [wp_6_capabilities] => Array
        (
            [administrator] => 1
        )

    [wp_6_user_level] => 10
    [wp_6_usersettings] => mfold=f&editor=tinymce
    [wp_6_usersettingstime] => 1322855647
    [wp_6_dashboard_quick_press_last_post_id] => 24
    [closedpostboxes_toplevel_page_appdashboard] => Array
        (
        )

    [metaboxhidden_toplevel_page_appdashboard] => Array
        (
        )

    [_viewed_jobs] => Array
        (
            [0] => 13
        )

    [wp_2_vantage_last_listing_id] => 196
    [user_level] => 10
    [user_firstname] => 
    [user_lastname] => 
    [user_description] => 
)

In WP 3.3:

stdClass Object
(
    [ID] => 1
    [user_login] => admin
    [user_pass] => $P$B2RBgdoaBDn7zWc/55YCMV3rI2ga7n/
    [user_nicename] => admin
    [user_email] => a@b.com
    [user_url] => 
    [user_registered] => 2011-10-26 14:21:09
    [user_activation_key] => 
    [user_status] => 0
    [display_name] => admin
    [spam] => 0
    [deleted] => 0
)

Attachments (1)

19595.diff (404 bytes) - added by scribu 3 years ago.

Download all attachments as: .zip

Change History (9)

@scribu3 years ago

comment:1 @scribu3 years ago

  • Keywords has-patch added

comment:2 @scribu3 years ago

Context: #15458

comment:3 @scribu3 years ago

Related: #19615

comment:4 @knutsp3 years ago

  • Cc knut@… added

comment:6 @ryan3 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [19624]:

Assign the full WP_User object to the userdata global. Props scribu. fixes #19595

comment:7 @ryan3 years ago

In [19625]:

Assign the full WP_User object to the userdata global. Props scribu. fixes #19595 for 3.3

comment:8 @nacin3 years ago

In [20087]:

$userdata should be null for anonymous requests. props duck_. fixes #19769 for 3.3. see #19595.

Note: See TracTickets for help on using tickets.