[wp-hackers] Custom taxonomies for authors

Mike Schinkel mikeschinkel at newclarity.net
Sat Mar 13 08:13:39 UTC 2010


On Mar 13, 2010, at 1:57 AM, Dion Hulse (dd32) wrote:

> On Sat, 13 Mar 2010 18:48:48 +1200, scribu <scribu at gmail.com> wrote:
> 
>> On Sat, Mar 13, 2010 at 3:06 AM, Thomas Scholz <info at toscho.de> wrote:
>> 
>>> 'usermeta' isn’t made for n:n-relationships. I’d rather use something like
>>> this:
>>> 
>>> register_taxonomy(
>>>       'color',
>>>       'user',
>>>       array(
>>>               'hierarchical'  => false,
>>>               'label'                 => 'Color',
>>>               'query_var'             => 'color',
>>>               'rewrite'               => array('slug' => 'color')
>>>       )
>>> );
>>> 
>>> But it doesn’t show any visible result (and I didn’t really expect it to
>>> do).
>>> 
>>> What would be the best way to implement this functionality?
>>> 
>> 
>> The second argument should be 'post' instead of 'user'.
>> 
>> What you really need is a 3 way relationship: post-color-user.
>> 
>> From a database perspective, this can be done by adding a user_id column to
>> the wp_term_relationships table.
>> 
>> It would involve some custom both on the admin side and on the front-end.
> 
> Personally i don't think creating it as a post taxonomy is what is needed here.
> 
> Thomas, I think the taxonomy way you are going about is the best method.
> As you can see, The taxonomy data is not shown to you however, since WordPress doesnt handle taxonomies being applied to users.
> 
> You can visit /wp-admin/edit-tags.php?taxonomy=color directly and you'll be able to manage the Colours there.
> 
> You'll need to manually add a dropdown selection to the user edit page however based off that taxonomy data, you'd probably have to hook into 'show_user_profile' & 'edit_user_profile' to add a new Table and table row, as well as saving that data manually through the action which fires when user data is updated...

At this risk of inciting a backlash, doesn't this give one good use-case (and I have many others of my own) why it would be a good idea to have users (and commenters) as a standard "person" post type, at least via a canonical plugin if not in core?

-Mike


More information about the wp-hackers mailing list