Page 1 of 1

How to Let some posts/teasers avaiable to unregistered users

PostPosted: July 26th, 2010, 6:13 am
by stefanogaruti
Hi Jason,
first of all thanks for your wonderful plugin! I'm staring a little membership with video-tutorials and would like to offer some "preview" and some teaser to my prospects.

All of my content is inside posts that belongs to the "modules" category (and som sub-categories).
I set up s2Member so that the "Modules" category is accesible only to level1 members.

How can I let WordPress show the post "teaser" (the lines before the !more tag) anyway even if in category-protected posts?
How can I exclude some arbitrary post (that are in the "modules", protected catecgory) so that thay show up anyway even to non registered users?

Maybe the more general question could be: how the restriction applyed at category level can be "by-passed" with conditional API?

Thanks for your attention!

Stefano

Re: How to Let some posts/teasers avaiable to unregistered u

PostPosted: August 5th, 2010, 8:10 pm
by Jason Caldwell
Thanks for the great question.
I sincerely apologize for the delayed response.
wordpressmania wrote:How can I exclude some arbitrary post (that are in the "modules", protected catecgory) so that thay show up anyway even to non registered users?

Maybe the more general question could be: how the restriction applyed at category level can be "by-passed" with conditional API?

OK. First off... ( for the benefit of other readers ) I don't recommend this. Instead, I would consider a fundamental restructuring of the way your "members only" content is grouped together, and/or categorized. s2Member makes a lot of methods available, that do NOT require the additional routines I'm about to describe. You can just use the s2Member -> General Options panel instead ( much easier ).

Now, to answer your question.
You will need to ( NOT protect ) the categories with s2Member, and instead, integrate your own Advanced Conditionals; inside your WordPress theme. Depending on how your theme is built, this will probably be inside your /index.php file. You will find a section that looks something like this:

The famous WordPress Loop
Code: Select all
<?php
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        the_content();
    endwhile;
endif;
?>

So you could do something like this, integrating some conditionals:
Code: Select all
<?php
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        if(has_tag("members-only") && !current_user_can("access_s2member_level1"))
            continue;
        else the_content();
    endwhile;
endif;
?>

So here, you are telling your theme to continue ( i.e. not to show ) any Post that has the tag "members-only". You can follow this link for a more in-depth look at WordPress Conditional Tags.

I've also done a video tutorial here on the topic of Advanced Conditionals:
http://www.s2member.com/advanced-conditionals-video/

Re: How to Let some posts/teasers avaiable to unregistered u

PostPosted: August 6th, 2010, 1:53 am
by stefanogaruti
Jason,
thank you for your reply!

I'll try it and came back with some feedback!