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™

How to Let some posts/teasers avaiable to unregistered users

s2Member Plugin. A Membership plugin for WordPress®.

How to Let some posts/teasers avaiable to unregistered users

Postby stefanogaruti » July 26th, 2010, 6:13 am

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
User avatar
stefanogaruti
Experienced User
Experienced User
 
Posts: 11
Joined: July 26, 2010

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

Postby Jason Caldwell » August 5th, 2010, 8:10 pm

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/
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

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

Postby stefanogaruti » August 6th, 2010, 1:53 am

Jason,
thank you for your reply!

I'll try it and came back with some feedback!
User avatar
stefanogaruti
Experienced User
Experienced User
 
Posts: 11
Joined: July 26, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 13 guests

cron