[wp-hackers] repeating fields in usermeta?

SoJ Web sojweb at indiana.edu
Thu Apr 16 17:00:24 GMT 2009


Well, the root of the problem was that there was no way to store user  
meta values with non-unique keys, and my intent was just to address  
that. I didn't want to take it too far all in one go :-). This just  
allows the key-value pairs to reside in unique rows in the database,  
which makes manipulation (searching & modifying) much easier. It  
doesn't directly address the problem of search, but that could easily  
be attended to by a plugin (or further development).


-Jeff

On Apr 16, 2009, at 12:34 PM, Silverstein, Jesse wrote:

> I haven't looked at your code, or in depth at the post_meta functions,
> so correct me if I'm wrong here, but if you're using built in  
> functions
> to accept and return arrays of data, isn't it still going to store the
> arrays as serialized strings? If so, how does this solve the initial
> problem of having to load all of the data into actual arrays before  
> you
> can search it?
>
> -Jesse
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of SoJ Web
> Sent: Thursday, April 16, 2009 12:28 PM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] repeating fields in usermeta?
>
> This could end up being useful for me, too, so I submitted a patch to
> an open ticket on the subject:
> http://core.trac.wordpress.org/ticket/7540
>
> The get_usermeta function could return an array of multiple values,
> but there didn't seem to be a way to set multiple values. I added a
> add_usermeta function (basically a copy of add_post_meta), and
> modified update_usermeta to allow for modification of value with same
> keys (in a way similar to update_post_meta). Behavior shouldn't change
> for current code. It seemed to work okay for me and what I'm doing,
> but I might not be considering all cases.
>
>
> -Jeff
>
> On Apr 16, 2009, at 9:23 AM, Casey Bisson wrote:
>
>>
>> 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.
>>
>>
>>
>>
>> On Apr 16, 2009, at 8:56 AM, SoJ Web wrote:
>>
>>> 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?
>>>>
>>>> --Casey
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.0.238 / Virus Database: 270.11.58/2061 - Release Date:
> 04/16/09 08:12:00
> _______________________________________________
> 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