PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Specific access and post types?

s2Member Plugin. A Membership plugin for WordPress®.

Specific access and post types?

Postby n1c0_ds » January 28th, 2012, 1:49 pm

Hello!

I just installed s2Member, and after browsing around, I haven't been able to find a way to allow specific access to post types.

For example, we have a list of shows which a user can purchase. Instead of entering each and every show's post ID in "Specific post/page access restrictions", we would like to simply enter the post type so our client doesn't have to update the options each time a new show is added.

This is the flow: User sees list of shows (custom post type: show), decides to purchase access to single show or to subscribe for a year and access all shows.

Is this possible?
User avatar
n1c0_ds
Registered User
Registered User
 
Posts: 5
Joined: January 28, 2012

Re: Specific access and post types?

Postby Cristián Lávaque » January 29th, 2012, 4:29 am

Why are you trying to use Specific Post/Page restriction for this? So it's not required to register an account for access? If so, I'm afraid it's not possible without some customization. Post Types are only supported in the Page Access Restriction so far.

If having the user register is not a problem, which I assume it may not be since you're planning to sell a yearly subscription, then you could instead use the category or tag access restrictions.

To sell individual shows, you may want to look at custom capabilities and control the access with conditionals. If you don't use the conditional and instead require the custom capability from the meta box in the edit page, you won't be able to sell the subscription without also giving that user all show's capabiliites. With a conditional you can check for the capability for that show or the subscription for all shows.

http://www.s2member.com/custom-capabilities-video/
WP Admin -> s2Member -> API / Scripting -> Simple/PHP Conditionals
WP Admin -> s2Member -> API / Scripting -> Advanced/PHP Conditionals


I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Specific access and post types?

Postby n1c0_ds » January 29th, 2012, 10:37 am

The spec is that the client should be able to subscribe for a year and watch all the shows he wants, or purchase a single show. If he purchases a single show, he should only be able to watch that one and only show, and the other ones he purchased. Would this be possible?
User avatar
n1c0_ds
Registered User
Registered User
 
Posts: 5
Joined: January 28, 2012

Re: Specific access and post types?

Postby Cristián Lávaque » January 30th, 2012, 11:16 pm

Yes, using custom capabilities for the individual shows and restricting access with conditionals, as I said above. Example:

Code: Select all
[s2If current_user_can(access_s2member_level1) OR current_user_can(access_s2member_ccap_showA)]
     Video player for Show A
[/s2If]


I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Specific access and post types?

Postby n1c0_ds » February 2nd, 2012, 12:03 pm

I'm not quite sure I get it. Bearing that a non-technical user might add an indefinite number of shows, the code should add itself once set up.

Is there a functionality that allows purchase of individual items regardless of the situation? From what I'm reading, you seem to suggest that I create a different subscription level for every single show. Considering that there might be as many as 5 shows a week, that would get very complicated very fast.

Thanks a lot for your time and patience. I'm fairly familiar with WordPress and its code, but s2m is new to me.
User avatar
n1c0_ds
Registered User
Registered User
 
Posts: 5
Joined: January 28, 2012

Re: Specific access and post types?

Postby Cristián Lávaque » February 3rd, 2012, 4:06 am

No, you don't need new levels for each show, just custom capabilities, which would be the name of the show. For example, let's say the user purchases access to the The Simpons, the ccap (custom capability) could be the_simpsons. The button to purchase the access would have that ccap, which after checkout will be added to the user's profile. Then when you check for this ccap if the user tries to load that show, the conditions would check current_user_can(access_s2member_ccap_the_simpsons).

http://www.s2member.com/custom-capabilities-video/

Now, if you added that ccap as a restriction to a page/post using the s2Member meta box on the right of the edit page, no one without that ccap in his profile would be able to see it. That's why I suggest that, instead, you use conditionals, so that it can either be the ccap or the Level 1 access what the user has that'd let him see the content.

I hope that makes sense.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Specific access and post types?

Postby n1c0_ds » February 4th, 2012, 3:44 pm

Ah yes, that's much clearer when explained that way. I'll look into that, thanks a LOT
User avatar
n1c0_ds
Registered User
Registered User
 
Posts: 5
Joined: January 28, 2012

Re: Specific access and post types?

Postby n1c0_ds » February 4th, 2012, 4:51 pm

Let's just make sure we are on the same page here.

Custom capabilities are equivalent to "special rights" a user can purchase regardless of its restriction level, like buying tickets to special rides in an amusement park.

Custom capabilities are not stored like categories, so any ccap could be purchased by a user if we created a button for it, and therefore, the PayPal buttons to purchase those could be created programmatically. We could have a PayPal button on each page that sells a capability named after the page ID, and check for each page if that ID capability was purchased.

The procedure would be the following:
- Put some conditionnal code that checks if the user has capability "show_[show id]"
- If he does, show the show. If not, put a message with a PayPal button
- After the user has paid for the show, he is prompted to login or create his account.
- The user can now watch the show.

Am I correct so far?
User avatar
n1c0_ds
Registered User
Registered User
 
Posts: 5
Joined: January 28, 2012


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 2 guests