[wp-hackers] Custom list of posts per user

Mike Schinkel mikeschinkel at newclarity.net
Tue Sep 14 23:10:10 UTC 2010


On Sep 14, 2010, at 6:54 PM, Kevin Newman wrote:
> I'm trying to create a plugin that will allow users to add any kind of post into a list that is associated with that user's account. I'd like to do this without relying on the addition of a table into MySQL (though that would probably be the easiest way to go).
> 
> Anyone know if that's been done before?
> 
> This kind of functionality would be useful for something like adding a product post-type to a cart (a list stored with the user) for example.
> 
> I had thought of using a hidden custom taxonomy, and filtering on that using either a hierarchical structure or associated data (doesn't seem possible). For hierarchical structure the idea is to add a top level term (or tag) for each user (based on their user id), then add any lists they create as children of that term - thereby limitting that term list to that user (and allowing for the admin to monitor and edit these lists). I haven't been able to find the necessary actions or filters to make that happen (I'd need something like an action for 'add_term' I'd guess).

Your hidden custom taxonomy is definitely creative and you might be able to get it to work but I fear you'd see many compatibility trouble with it than you know with other plugins are unaware of your custom usage on taxonomy.

One option I'm sure you've considered is to add an array value to wp_postmeta.  Of course that is relationally horrible and you can't run JOIN queries using foreign keys in serialized arrays so I'd hope nobody would do that in a plugin.

IMO the best option is to add a table (and I loathe adding tables) since this is a type of relationship that simply can't be robustly simulated using the current tables in WordPress core.  I proposed[1] adding a post-to-post relationships table to core but the proposed table could just as easily do double duty for post-to-user as well.

-Mike
[1] http://core.trac.wordpress.org/ticket/14513


More information about the wp-hackers mailing list