• Can custom capabilities bestow other custom capabilities?

    I sell about 30 separate lessons that I plan to give access to using a level 1 membership coupled with custom capabilities (access to each lesson is granted by its own custom capability – ccap: 1 gives access to lesson #1, etc). I also sell various bundles of these same lessons, and I would like to simply sell a bundle capability.

    My question is this – Can I restrict the lesson #1 post/page by requiring EITHER ccap: 1 OR ccap: X?

    https://wordpress.org/plugins/s2member/

Viewing 15 replies - 1 through 15 (of 21 total)
  • Yes, try this:

    [s2If current_user_can(access_s2member_ccap_your1ccap) OR current_user_can(access_s2member_ccap_your2ccap)]

    I’d do it a different way. Just create other levels, above level 1, that represent bundles of capabilities. Then a user will be able to access a post/page either by ccap or by the relevant level.

    To add the appropriate capabilities to each level, use a plugin like Capability Manager Enhanced.

    Thread Starter statstutor

    (@statstutor)

    @krumch Where would I put that? Right in the

    Require Custom Capabilities?

    section of the S2Member box on a protected page?

    ——————————————–

    @kts915 Could this work though with more than one bundle? It seems to me that since higher levels inherit the capabilities of lower levels then I could only do this with one bundle.

    I need to be able to sell the following:

    • Any of lessons 1-30 individually
    • lessons 1-15 as a bundle
    • lessons 10-20 as a bundle
    • lessons 16-30 as a bundle

    @statstutor,

    Higher levels inherit the inherent capabilities of the levels below, but not the custom capabilities added to each level.

    So you could have as many bundles or levels as you want, because you’d be able to choose what bundle of ccaps can be accessed at each level.

    Thread Starter statstutor

    (@statstutor)

    I understand that, but how would this work in terms of actual level capabilities for level 1, level 2, etc. I don’t see it at all.

    Let’s say John wants to buy access to lessons 1-15, Sue wants only lessons 8 and 20, and George wants lessons 10-20. What can be done here with different levels acting to bundle capabilities?

    Thread Starter statstutor

    (@statstutor)

    Comma delimited ccaps in the metabox represent AND logic. Is there a method for entering OR logic into the metabox?

    @statstutor,

    Everyone gets level 1. Individual ccap purchases are added to level 1.

    Level 2 could be ccaps 1-15, level 3 could be ccaps 10-20, level 4 could be 16-30.

    By entering the shortcode in the page like Krum mentioned, the page itself won’t be protected, meaning that the page will OPEN, but the content will be protected. This also gives you the opportunity to have some content displayed with another shortcode on that same page, like this:

    [s2If !current_user_can(access_s2member_ccap_your1ccap) AND !current_user_can(access_s2member_ccap_your2ccap)]
    Sorry, you can only access this content once Lesson 1 is completed
    [/sIf]

    So that page won’t show your protected content, but will also inform your visitors why they can’t see it (you might put a link to direct them to that Lesson 1 or where they can register for it).

    Thread Starter statstutor

    (@statstutor)

    Thank you everyone for your answers. Just so I am clear, it is NOT possible to make use of OR logic when using ccaps to restrict entire posts or pages?

    @kts915 If everything is being done with ccaps, then why bother with the different levels? Why not just use level 1 for everyone and add whichever ccaps are required to form the desired combination of lessons? This is what I had figured was the solution from the outset, and I am still not seeing what level 2 could gainfully inherit from level 1, or what level 3 could gainfully inherit from level 2. My products are not tiered.

    @cassel I would have made use of this technique, but my lesson pages rely heavily on the wordpress comments section, and I wold also need that to only be accessible for users with the proper ccap. Is this possible?

    Thread Starter statstutor

    (@statstutor)

    Thank you everyone for your answers. Just so I am clear, it is NOT possible to make use of OR logic when using ccaps to restrict entire posts or pages?

    @kts915 If everything is being done with ccaps, then why bother with the different levels? Why not just use level 1 for everyone and add whichever ccaps are required to form the desired combination of lessons? This is what I had figured was the solution from the outset, and I am still not seeing what level 2 could gainfully inherit from level 1, or what level 3 could gainfully inherit from level 2. My products are not tiered.

    @cassel I would have made use of this technique, but my lesson pages rely heavily on the wordpress comments section, and I wold also need that to only be accessible for users with the proper ccap. Is this possible?

    @statstutor,

    Because, among other things, using levels enables you to create pre-packaged bundles. There are other reasons too, but I’m not interested in trying to persuade someone who’s resistant. It’s your choice.

    Thread Starter statstutor

    (@statstutor)

    @kts915
    It’s not that I am resistant, I really don’t understand the mechanism. How do levels allow you to create multiple parallel bundles that are not tiered with one-another? Please trust me that I do want this to work, and I do want to understand. I have been working on this for some time now and I am getting very frustrated.

    Perhaps I can give an example of what I’ve seen in another membership plugin – Groups for woocommerce. There you can create a ccap that allows you to read Page X, and another ccap to read Page Y, and another for Page Z. Beyond this however, you can also create a ccap that gives you both ccap_Page_X and ccap_Page_Y, another ccap can give you ccap_Page_Y and ccap_Page_Z, and another can give you ccap_Page_X and ccap_Page_Z. These bundles do not build upon each other, instead they present different combinations of the same basic components. S2Member seems only to be able to do this in a tedious manner – sell a membership with an attached list of all of the basic ccaps required. I thought there might be a way around this method.

    @statstutor
    Right, you cannot use the OR logic with the page/post restriction (i tried and i wished).

    I have my entire site using only the level 0 (free subscribers) and Level 1 (paid subscriber). Some sites and courses and content lend themselves easily to using tiered levels, but not all.

    I don’t know about the comments as i never use them on pages. My guess is that you can test it on a sample page and give someone the link and see what they can see without the proper access. Maybe it will work?

    Also, i never protected posts, only pages (and i have over 200 pages that are protected).

    Hope it helps, somewhat.

    @statstutor,

    I said earlier in this thread: “Higher levels inherit the inherent capabilities of the levels below, but not the custom capabilities added to each level.”

    You replied: “I understand that.”

    But evidently you don’t, because you have just said again that you want “bundles [that] do not build upon each other, instead they present different combinations of the same basic components” and at the same time complain that “S2Member seems only to be able to do this in a tedious manner – sell a membership with an attached list of all of the basic ccaps required. I thought there might be a way around this method.” Yet what you are asking for is precisely what my suggestion would provide.

    I suspect that you haven’t looked at the Capability Enhanced Manager plugin that I previously suggested. Take a look at it, and then you’ll see what can be done when combined with s2Member.

    Thread Starter statstutor

    (@statstutor)

    I do understand that levels do not inherit ccaps. I’ve been working with this plugin for years. I don’t think you’re understanding at all what I’m asking. Thank you for your time, but I’ll try to find my answers elsewhere.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Is any custom capability logic possible?’ is closed to new replies.