[wp-hackers] get_user_meta returning empty string
Andrew Nacin
wp at andrewnacin.com
Thu Nov 25 17:06:10 UTC 2010
On Thu, Nov 25, 2010 at 11:42 AM, Muro, Matthew <mmuro at advance.ua.edu>wrote:
> Is this because functions are deprecated so much (even though get_user_meta
> has already replaced the deprecated get_usermeta)?
>
> Like I said before, I don't mind switching my methods for the right reasons
> as long as I get WHY.
>
> Thanks for the input, everyone.
Not at all, get_user_meta isn't going anywhere. We rarely deprecate
functions (100 of 4,000 over 7 years), and even when we do so, they
typically remain functional.
However, you're using get_user_meta to fetch internals. What you're doing
isn't much different from a direct SQL call. There's a reason why there's
another layer of abstraction for the roles/capabilities system (as well as
many other APIs) -- so you can use it.
We're very likely to change how roles and capabilities are stored in the
database in a future release, perhaps 3.2 or 3.3. If you continue to use
WP_Role, WP_Roles, WP_User, and related (proper) functions, nothing will
break. If you go straight to the database, I pretty much guarantee your code
will break.
For what it's worth, some sites do not store role definitions in the
database. One more reason to use the API.
More information about the wp-hackers
mailing list