Opened 11 years ago
Closed 11 years ago
#24636 closed defect (bug) (wontfix)
WP_User has no method to access WP_User->data
Reported by: | dd32 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5 |
Component: | Users | Keywords: | has-patch |
Focuses: | Cc: |
Description
While working on #24635 I noticed that the WP_User class doesn't have a method to access the data field, while it has magic getters and setters, plus a to_array() method.
It seems appropriate that we should have a getter for the entire data object to go along with them.
Attachments (1)
Change History (6)
#2
@
11 years ago
- Version changed from trunk to 3.5
Seems like $user->data is probably good for now.
#3
@
11 years ago
- Keywords has-patch added; needs-patch removed
Added get_data method, in my opinion it's better to use getters/setters than public properties.
#4
@
11 years ago
Talked this over with Nacin and my patch can be ignored/removed.
Although the $data
property isn't private, it's not supposed to be public either. The guideline Nacin uses at the moment is changing properties that should be public to public
, while leaving those that should be private or protected at var
. The $data
property in this case should be private, so creating a getter for it would give people the idea that it should be used publicly.
I suggest closing the ticket, agree dd32?
You can already do
$user->data
, since it's not actually private.