Hide topics or thread based on ccaps

In my bbpress/buddypress forum, I would like to have a “private” section restricted based on a specific ccaps. So far, the best I can do is use the restriction under " Require Custom Capabilities?" However, it shows the thread in the forum BUT redirects to the Membership option page, which, in this case, is not what I want. I would rather the thread/topic be simply NOT displayed if the user does not have the proper ccaps (or they are not logged in).

I know I could do that with a “forum”, but i don’t want a whole forum protected; only a topic OR a thread because I will want to have individual “cohorts” of students.

How can I do that?

1 Like

That’s a good question…

So you can protect the thread, but you’d like to prevent it from being linked to if the user can’t view it, right?

Did you try with the Alternative Views protection? I haven’t tested and don’t remember if it works with ccaps, though… WP Admin > s2Member > Restrictions > Alternative View

It’s funny that you bring up this question now, because just yesterday I was thinking about improving what’s possible to do with s2 on bbPress. I will likely develop this idea and bring it out as an addon.

For now, if the Alt View restriction doesn’t work out of the box for ccaps, you’ll probably have to work with your theme for the forum, and add a conditional for the ccap in the loop that loads the topics.

I look forward to your update, and feel free to give me a wish list for ideas of what I could implement for an improved bbPress integration.

:slight_smile:

I will search that further.
It is interesting that I can protect a “forum” the way I want, but not the sub-sections. So, it should not be too hard to “carry over” the same thing for topics/threads??

As a suggestion (which might even be useful for other pages/posts) would be to not automatically redirect to the Membership Option page, but have the option to redirect to a different page. This would definitely add a lot of flexibility in the content restriction.

1 Like

Thanks!

Yes. A custom restriction redirection is something I have in mind too. Not specific to bbPress, but in general.

About the forum, how are you protecting it? With a ccap, or with the level URI restriction? Could you describe more how the protection of the forum is working more the way you want?

The way I will do it, for now, is by creating a “forum”, and protect it by ccap. For now, I have only one group. Hopefully, by the time I have the next “class”, another option will be available. If not, this group will be over so I might just hide it altogether.

So, right now, I have one “forum” called “Study group”.
It is protected by ccap, as the proper ccap for its visibility/access is “basic_march2021”.
https://scrapbookcampus.com/community/
If you have that ccap, you should see it (it is at the bottom of the page, after the “Creative Scrap Course”.
If you don’t have the ccap (or are not logged in), you don’t see that section at all.

The other option I was trying to do, was to protect a “thread”. I put it inside the “forum” called “Basic Scrap Course” (since this group would be studying that particular set of tutorials.
I called that Topic “Basic Study Group – March 2021”.
It is also protected with the same ccap, however, it is visible, even if you don’t have the access.
Then, without the access, clicking on that thread, you are then redirected to the Membership option page (in my case, it does not really have OPTIONS).

Maybe this can give you a glimpse into what would be interesting to have.

1 Like

Got it! I think I understood better what you want.

If I understood you correctly this time, then it’s something you can already do. I just tested it in my bbPress installation.

Just as protecting the Forum will make it not show to someone without that access, protecting a topic will make it not be shown in the forum’s topics list.

When you tested if you can see the topics, were you logged in as the admin or as a normal user?

:slight_smile:

OK, I retested something and it works now. I swear it was NOT behaving like that this weekend!
I’ll keep testing more but it looks like it does what it is supposed to do… now!

1 Like

Wonderful! I’m very glad.

I had just replied your PM before seeing your update here.

Let me know when you need help again. :slight_smile:

If there is anything that could be looked into would be to have any ccap restrictions (forum, pages, posts) possibly combined with AND or OR. Right now, if two ccaps are used, the member has to have them BOTH, which is limiting if one content should be available under different possible ccaps.

The example I have in mind is that if that “Study group” section is reserved for anyone who has one of the different groups ccaps (ex: study_march2021, study_april2021, study_may2021) but right now, the only way would be to create another ccap (ex: “study”) to protect the content. It just ends up adding more ccaps than needed.

If you want me to make it into a separate thread to keep track of suggestions, I can do that too.

1 Like

No need. Yeah, that’s a great point. I do have it very much in mind. If not a way to pick AND from OR, I may at least make the OR the default. The tricky part is that some site owners will already have restricted with two ccaps or more, expecting them all, so I can’t change the behavior for them. I’ll think of something.

I’m currently working on a couple new features that will be released soon as addons, and also want to work on revamping the admin pages a bit. After that, I may include a way to make this possible.