latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Next and previous posts with same ccap?

Home Forums Community Forum Next and previous posts with same ccap?

Tagged: ,

This topic contains 5 replies, has 3 voices. Last updated by  Raam Dev 4 years, 2 months ago.

Topic Author Topic
Posted: Wednesday Oct 24th, 2012 at 6:48 pm #29597

I’ve tried to solve this before, but I’m still banging my head against a wall. Any help is appreciated.

I have several posts protected by the same ccap. I’m trying to show a next/previous navigation that goes among those posts only, without including any other posts at all. I don’t need to worry if the user has permission to access them, just that the next/prev links only show posts with the same ccap.

Any help on how I could accomplish that? It’s such a niche question that I’m having trouble finding anyone, anywhere on the internet that knows.

Thank you!

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Thursday Oct 25th, 2012 at 7:23 am #29630

Well, you’d need to query the db to find the posts with that ccap, sort them to know the order, and then you’ll have the previous and next one to the one being viewed.

Currently there isn’t a function to query these that way, so you’ll need to code this one yourself.

A simpler approach, though, may be adding to every post, a tag that matches the ccap. Then you have the tags navigation and functions available.

I hope that helps. :)

Posted: Thursday Oct 25th, 2012 at 12:28 pm #29655

Thanks Cristián. Could you give me a clue about how to get the ccap of the current post? I think I can figure the rest out.

Posted: Thursday Oct 25th, 2012 at 2:39 pm #29680
Raam Dev
Username: Raam
Staff Member

If you query the wp_postmeta table WHERE post_id = ‘$post_id’ AND meta_key = ‘s2member_ccaps_req’, you’ll get a row that contains a meta_value column containing a serialized array, which will contain the Custom Capabilities that are required to access that post. (e.g., a:1:{i:0;s:18:”my_custom_capability”;}).

Posted: Thursday Oct 25th, 2012 at 4:09 pm #29693

Thank you!

Posted: Friday Oct 26th, 2012 at 12:56 pm #29825
Raam Dev
Username: Raam
Staff Member

Glad to help! :)

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.