[wp-hackers] repeating fields in usermeta?

SoJ Web sojweb at indiana.edu
Thu Apr 16 17:10:49 GMT 2009

They seemed small enough and similar enough that just modifying them  
would work, and adding where it's needed (like an add_usermeta  
function). That also avoids deprecating functions.


On Apr 16, 2009, at 12:35 PM, Casey Bisson wrote:

> In comparing the various *_post_meta functions against the  
> *_usermeta functions, it looks like the post meta stuff has had a  
> lot more development cycles than user meta. Though I may be saying  
> that only because the post meta functions have stronger caching  
> support.
> Here are the two sets of functions:
> Post meta, found in wp-includes/post.php:
> http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php
> add_post_meta()
> delete_post_meta()
> get_post_meta()
> update_post_meta()
> delete_post_meta_by_key()
> update_postmeta_cache()
> User meta, found in wp-includes/user.php:
> http://core.trac.wordpress.org/browser/trunk/wp-includes/user.php
> delete_usermeta()
> get_usermeta()
> update_usermeta()
> Implementing post meta-style support looks pretty easy, especially  
> if I adopt the *_post_meta functions as the base, rather than trying  
> to start with the *_usermeta functions. Backwards compatibility  
> could then be maintained by calling the new functions from the old.  
> That approach looks a lot more straightforward than patching up the  
> existing *_usermeta functions, even if it would likely result in a  
> larger overall patch.
> Thoughts?
> On Apr 16, 2009, at 10:13 AM, SoJ Web wrote:
>> Yeah, looking at the function, that would be a pain. I'm surprised  
>> the user meta functions don't allow returning arrays of meta  
>> values; I'd think having that ability would be ideal, and it  
>> shouldn't be hard to patch. You'd have the added benefit of it  
>> being consistent with the way the post meta function works.
>>> Storing email addresses in a serialized array would make searching  
>>> for a user by email address difficult.
>>> My choices so far appear to be:
>>> Create a separate table for email addys.
>>> Create my own functions to enter and read email addys in usermeta.
>>> Patch the existing functions to support this use case while  
>>> maintaining backwards compatibility.
>>>> Would it not be possible to store the e-mail addresses and phone  
>>>> numbers as serialized arrays under one meta key?
>>>>> An application I'm working on needs to store an arbitrary number  
>>>>> of email addresses and phone numbers per user. The wp_users  
>>>>> table obviously isn't the place, but the wp_usermeta table might  
>>>>> not be either. The get_ and update_usermeta functions aren't  
>>>>> built for it, anyway.
>>>>> The various postmeta functions are very smart about handling  
>>>>> multiple entries of the same meta_key per post, but not the  
>>>>> usermeta functions. Is that by design?
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list