Page 1 of 1

PostAccess Restrictions without redirect and without login

PostPosted: January 10th, 2012, 5:33 pm
by InfoKing
Hi! Thanks for great plugin! I want to buy the pro-version, but first I need your help! :?
I want to show only the_excerpt from each post and hide the_content. I want to place the paypal-button directly to the post-template (see below), the user should not be redirected to the options-page! To see the entire post, the user should use BuyNow. Than he should have access only to this one post. I think that might work like this:

Code: Select all
<?php if (current_user_can("access_s2member_ccap_1")){ ?>
        <?php the_content(); ?>
<?php } else { ?>
        <?php the_excerpt(); ?>
        <p>Bitte kauf diesen Artikel, um den Inhalt zu sehen</p>
        <!-- PayPal BuyNow Button Code -->
<?php } ?>

So that he can only see this one post, I have to create for each post one ccap, right? Not pretty, but might work.
But now comes the big problem: I want that the user must not register!
Is this only possible if I use Specific Post Restrictions? But then the user will be redirected and i dont want to redirect. :(

I've seen something like this in the Plugin EasyPayPal.
Usage:
[paybutton]{Item Name*}|{Item Number*}|{Amount*}|{Currency Code}|{Subscription Days}|{Hidden Text}[/paybutton]*Required
Simple Pay Now (No Login Required)
http://www.voiceoftech.com/swhitley/?page_id=129

How is it possible with S2Member?

Sorry for the bad English. I hope you can help! :)

Re: PostAccess Restrictions without redirect and without log

PostPosted: January 11th, 2012, 2:52 pm
by Raam Dev
Hi InfoKing,

If you don't want the user to register, you should use Specific Post/Page "Buy Now" buttons. You don't use Custom Capabilities (ccaps) for this. You will need to generate the code one time for each post/page that you want to sell. Once you generate the button code, you can put that code into your page template.

Here's the process:

1) Protect the page in s2Member by going to WP Admin -> s2Member -> Restriction Options -> Specific Post/Page Access Restrictions
2) Go to WP Admin -> s2Member -> PayPal Buttons -> PayPal Specific Post/Page (Buy Now) Buttons
3) Select the page that you protected in Step 1 and set the price/description options
4) Click 'Generate Button Code'
5) Copy the 'Resulting PayPal Button Code' (NOT the shortcode, the shortcode won't work in your PHP page template)
6) Add the button code to your page template where the PayPal button should show up.

When a user clicks on that button, they will be sent to PayPal. Once they finish paying, they will immediately be transferred back to the protected page where they will have full access to it. They will also receive an email with an access link to view the page (good for 72 hours by default).

Re: PostAccess Restrictions without redirect and without log

PostPosted: January 11th, 2012, 4:18 pm
by InfoKing
Hi Raam, thanks for your answer!
Yes, that's fine. But if I use "Specific Post/Page Access Restrictions", how can I show a part of the post for someone who has not bought?
I need something like that code, but for Specific Post/Page Access Restrictions!
Code: Select all
<?php if (current_user_can("access_s2member_ccap_1")){ ?>
    Some content for Members who has bought this post. For example the_content
<?php } else { ?>
    Some public content. For example the_excerpt
<?php } ?>

Do you understand my problem?

Maybe I could use ws_plugin__s2member_sp_access in the page template to detect if the visitor has bought the post and show different content??

Re: PostAccess Restrictions without redirect and without log

PostPosted: January 15th, 2012, 12:22 am
by Jason Caldwell
Thanks for the heads up on this thread. While there currently is no API Function for this, as you've already discovered, there is an underlying class method which can be used accomplish what you need here.

Code: Select all
<?php
$post_or_page_id 
= get_the_ID();
if(
c_ws_plugin__s2member_sp_access::sp_access($post_or_page_id, "read-only"))
    {
        // The current visitor has Specific Post/Page Access to this Post/Page.
    }
?>


Code: Select all
<?php
if(c_ws_plugin__s2member_sp_access::sp_access(123, "read-only"))
    {
        // The current visitor has Specific Post/Page Access to Post ID #123.
    }
?>

Re: PostAccess Restrictions without redirect and without log

PostPosted: January 17th, 2012, 5:09 pm
by InfoKing
This works fantastic! Thank you so much! :)

Re: PostAccess Restrictions without redirect and without log

PostPosted: January 18th, 2012, 1:23 pm
by Raam Dev
Thank you for the update! Glad to hear it worked! :)