[wp-hackers] usermeta

Alan J Castonguay alan at verselogic.net
Thu Sep 28 02:20:07 GMT 2006


While on this topic, what should be done to store a list of values  
for a user? Let's say I wanted to 1-5 urls for each user. Does the  
{userid,metakey} tuple have to be unique, or can I add/retrieve  
records like

id, uid, metakey, metavalue
45, 1,      theurl,   http://google.com
45, 1,      theurl,   http://wordpress.com
45, 1,      theurl,   http://example.com

I believe that the above cannot be done. As an alternative, a  
serialized array of urls could be stuffed into the metavalue, which  
is a `longtext`. Assuming that urls don't get long or numerous, this  
could work. What's the preferred method of storing a list of user  
metadata?


On 27-Sep-06, at 5:38 PM, Austin Matzko wrote:

> Actually, isn't that plugin just for WordPress 1.5, before the
> usermeta tables were included?
>
> The usermeta table seems pretty simple: you have three columns of
> importance: one for user ids, one for the meta key, and another for
> the meta value.
>
> get_usermeta( $user_id, $meta_key = '') returns the meta information,
> given a user id and the key value.
>
> update_usermeta( $user_id, $meta_key, $meta_value ) updates the meta
> value for a specific user, meta key


More information about the wp-hackers mailing list