1

I searched in WordPress Codes, and all of the online forums and tutorials about this but could not find any relevant solution. What I am trying to achieve is to create a query that lists posts for a logged in user from the user specific meta key value.

Basically , users will click on a checkbox on frontend and mark the post as Read. Once they do so, a custom field value sets in the user meta table for that specific user. The value could be True or False.

For example if user A has marked post 1 as Read (True) and user 2 not, then the query will show only that post to user A only and not to user B.

Any guidance in the right direction would be highly appreciated.

  • How do you tell if user A has read a specific post? like, if user A reads posts 1, 2,3 and 4, and user B reads posts 2, 4, 6 and 9, what does the meta table look like? – Taruc Jan 15 '16 at 23:20
  • @Taruckus there is a checkbox present on each post. Any user who clicks on it, a value of TRUE will set in users_meta_table for that user only. In the same way if he unchecks it, a value of FALSE will be set. – bakar Jan 16 '16 at 10:51
  • What is the meta_key? – s_ha_dum Jan 17 '16 at 14:10
  • Meta Key = test_item_key and it has two values, either True or False. Here is a screenshot from database screencast.com/t/UTYpnSdW – bakar Jan 17 '16 at 14:23
  • how do you know which post the user was viewing when they checked the box? – Milo Jan 17 '16 at 19:53
0

Best way i think would be to add an array of read post IDs to the user meta table and use them in the 'post__not_in' Parameter in the pre_get_posts hook. In my mobile right now, so i will edit this answer once i'm at work to insert a code example.

  • any update on the code example? – bakar Jan 19 '16 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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