Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Any search keyword suggestions to help would be appreciated - not sure how best to describe this query :)

I have a custom post type "module". I have ~300+ modules in my install. I have ~100+ registered users (Subscriber role)

Query: I want to allow users to mark a "module" as "Complete" using a checkbox, and be able to get that info from DB when I'm generating lists of modules.

Is there a plugin or hack available or any suggestions if I need to code it up myself? Any other suggestions?

share|improve this question
    
[I'm the OP, just registered] Thanks for the replies folks. I'm quite familiar with setting custom fields so no problem doing that. BandonRandon is right on the mark - the problem here is that we need to store a 2d array either as a custom field for each post with a bunch of user id, or as a custom preference for each user, with a bunch of post ids. That's why I'm wondering if someone's already invented the wheel, and if not, which approach is better? I'm thinking each user has their own list of completed post ids, I think that probably should be more scalable than each post having userids. An –  AMcDermott Apr 13 '11 at 23:25
    
First: Please update your Q or comment on As. Do not add comments or Answers to your own Q. The system is meant to work otherwise. Ad your Q) Question yourself what happens if a user or a post get's deleted and how you'd handle that. Is it ok to have completed posts without the according User? Is it ok to have post IDs in user meta of posts that doesn't exist anymore? –  kaiser Apr 14 '11 at 2:01
    
@kaiser: wilco, thanks for steering me right on how Q&A works, my first time here so apologies for that. Yeah, you nailed it as to why I think each user should have an array of posts. –  AMcDermott Apr 14 '11 at 2:16
    
No apologies needed. Everybody runs into this. Ad Q) Imo it would be best to have both. So if a user get's deleted, you can assign it someone other or revert the status. On the user side you could this way later implement a reputation system like here on WA and revert points if a post get's deleted. Makes it much easier. And you can target both from both sides. You also got the user present with it's data. Trying to get all posts without the IDs saved at the user meta would require additional queries and vice versa. I always prefer DB-space before queries. –  kaiser Apr 14 '11 at 11:31
    
Think I need to work on this code before showing it publicly again :) –  AMcDermott Apr 14 '11 at 22:46

1 Answer 1

You can use a "custom field" for marking the items as complete. These are also known as post meta fields. To set and read these fields, you'll use the WordPress functions update_post_meta() and get_post_meta(), respectively.

As for actually allowing users to set this flag from the frontend, AJAX seems like the best way. Check out the Codex article on AJAX, specifically the section titled "Ajax on the Viewer-Facing Side".

You can build this all out as a plugin, or you can simply include your code in your theme's functions.php file.

share|improve this answer
    
+1 i hove done something just like this, I'll look for the code when i get hope. –  Bainternet Apr 13 '11 at 19:07
2  
Correct me if I'm wrong but wouldn't you need a custom field for each user? Either that or store a comma separated list of user ID's that have "completed" the task. –  BandonRandon Apr 13 '11 at 20:44
    
Hi folks, I added some code samples below, what do you think? –  AMcDermott Apr 15 '11 at 14:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.