[wp-hackers] get_users() fields array parameter
Chip Bennett
chip at chipbennett.net
Thu Dec 13 16:58:50 UTC 2012
I recently tried passing 'fields' => 'user_email' in the arguments array
for get_users(). Instead of returning user email addresses as expected, the
call returned user IDs.
var_dump( get_users( array( 'fields' => 'user_email' ) ) );
outputs:
array(3) { [0]=> string(2) "10" [1]=> string(1) "9" [2]=> string(1) "1" }
According to the Codex, this should be an array of user
emails<http://codex.wordpress.org/Function_Reference/get_users#Example_for_Array_of_Values_when_single_Field_specified>
.
Is this a bug? Can anyone reproduce? (I found nothing related in Trac.) Or
am I doing something wrong?
Note, if I make 'fields' an array, I get an array of objects that *do*
consist of user_email values:
var_dump( get_users( array( 'fields' => array( 'user_email' ) ) ) );
outputs:
array(3) { [0]=> object(stdClass)#620 (1) { ["user_email"]=> string(22) "
testeditor at example.com" } [1]=> object(stdClass)#621 (1) { ["user_email"]=>
string(26) "testsubscriber at example.com" } [2]=> object(stdClass)#622 (1) {
["user_email"]=> string(20) "chip at chipbennett.net" } }
Just doing a sanity check before submitting a bug report, and/or updating
the Codex.
Thanks,
Chip
More information about the wp-hackers
mailing list