[wp-hackers] Seeking SQL advice to identify performance problem
Otto
otto at ottodestruct.com
Wed Jun 20 16:07:44 UTC 2012
On Wed, Jun 20, 2012 at 10:06 AM, Mike Walsh <mpwalsh8 at gmail.com> wrote:
> I must be missing something as I am unable to retrieve the first_name and
> last_name fileds using get_users(). Here is an example (this is dummy
> data, not from a real user) of what I get back when I call get_users() as
> outlined below:
>
> [885] => WP_User Object ( [data] => stdClass Object
> ( [ID] => 885
> [user_login] => aarntzen [user_pass] =>
> $P$BFVck6WesTLX9SboEeNAaaaDxZQfx81 [user_nicename]
> => aarntzen [user_email] =>
> aarntzen at wpst.example.com [user_url] =>
> [user_registered] => 2012-06-19 14:53:28
> [user_activation_key] => [user_status] => 0
> [display_name] => Alejandro Arntzen )
> [ID] => 885 [caps] => Array (
> [subscriber] => 1 ) [cap_key] =>
> wp_capabilities [roles] => Array (
> [0] => subscriber ) [allcaps] =>
> Array ( [read] => 1
> [level_0] => 1 [subscriber] => 1 )
> [filter] => )
>
> This is how I called it:
>
> $args = array(
> 'fields' => 'all_with_meta'
> ,'exclude' => $exclude_id
> ,'number' => 25
> ) ;
> $users = get_users($args) ;
>
> Am I missing something?
Yes, you're missing the power of "magic" methods. Just because you
don't see it in a var_dump() doesn't mean that it isn't there.
Your code works perfectly. Just ask it for the first and last names,
and you'll find that it returns them to you just fine.
foreach($users as $user) {
echo $user->first_name.' '.$user->last_name;
}
-Otto
More information about the wp-hackers
mailing list