Discussion:
get_users() magic methods revisited
Mike Walsh
2014-02-24 17:06:24 UTC
Permalink
A while ago I posted a question which resulted in a suggestion to rely on
the "magic methods" of get_users() to reference the first name and last
name fields stored as user meta data.

http://lists.automattic.com/pipermail/wp-hackers/2012-June/043340.html

I am revisiting this because I've had a report from one user of a plugin
which makes uses of this that their first name and last name fields are
always empty. Does anyone know of a reason why in some instances this data
wouldn't be populated?
--
Mike Walsh - ***@gmail.com
Nikola Nikolov
2014-02-24 18:13:11 UTC
Permalink
Which version of WP are they using? I think that before the introduction of
the WP_User object, objects returned from get_users() were just normal
StdClass objects which therefore don't have magic methods and would return
null(I believe) when you try to access an unset property(and raise a
warning depending on the error levels) which in turn when converted to
string becomes an empty string.
Post by Mike Walsh
A while ago I posted a question which resulted in a suggestion to rely on
the "magic methods" of get_users() to reference the first name and last
name fields stored as user meta data.
http://lists.automattic.com/pipermail/wp-hackers/2012-June/043340.html
I am revisiting this because I've had a report from one user of a plugin
which makes uses of this that their first name and last name fields are
always empty. Does anyone know of a reason why in some instances this data
wouldn't be populated?
--
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Mike Walsh
2014-02-24 18:16:21 UTC
Permalink
That is my suspicion as well. I don't have an answer yet as to what
version of PHP and what version of WordPress the person reporting the
problem is running on. According to the Codex, the WP_Users magic methods
were added in 3.3 so it is hard for me to believe this user is using a
version of WordPress that old.
Post by Nikola Nikolov
Which version of WP are they using? I think that before the introduction of
the WP_User object, objects returned from get_users() were just normal
StdClass objects which therefore don't have magic methods and would return
null(I believe) when you try to access an unset property(and raise a
warning depending on the error levels) which in turn when converted to
string becomes an empty string.
Post by Mike Walsh
A while ago I posted a question which resulted in a suggestion to rely on
the "magic methods" of get_users() to reference the first name and last
name fields stored as user meta data.
http://lists.automattic.com/pipermail/wp-hackers/2012-June/043340.html
I am revisiting this because I've had a report from one user of a plugin
which makes uses of this that their first name and last name fields are
always empty. Does anyone know of a reason why in some instances this
data
Post by Mike Walsh
wouldn't be populated?
--
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
Mike Walsh - ***@gmail.com
Loading...