Community Support Forums — WordPress® ( Users Helping Users ) — 2011-11-15T03:01:25-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=15899 2011-11-15T03:01:25-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15899&p=53018#p53018 <![CDATA[Re: Membership only for older posts]]> By the way, I wonder why this membership model (newest posts free for every visitor) isn't used more offen, because it seems an option if your website is depending on ads also.

Statistics: Posted by ronhen — November 15th, 2011, 3:01 am


]]>
2011-11-14T22:37:20-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15899&p=52991#p52991 <![CDATA[Re: Membership only for older posts]]>
I recently did something similar with s2Member. It required modifying my single.php theme file.

What I did was check if the post was less than 30 days old. If the post is less than 30 days old *OR* the person viewing it is logged in, then display the post.

Otherwise, (if the post is older than 30 days old and the person viewing it is NOT logged in) display a message that says they need to be a member and give them a link to subscribe.

Here's an example code from my own single.php. Your theme file will look slightly different, but the concept is the same.

Code:

    <div id="content">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

        <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
            <h2><?php the_title(); ?></h2>

                <?php
                $restrict_after
=30 * 86400; // days * seconds per day (30 days)
                $post_age = date('U') - get_post_time('U');
                if ($post_age < $restrict_after || is_user_logged_in()) { ?>
                    <div class="entry">

                        <?php the_content(); ?>
                                
                    </div>        

                <?php }
                else { ?>
                    <div class="entry">                    

                           <p>This post is older than 30 days and can only be accessed with a <a href="http://example.com/join /">membership</a>. If you already have a membership, please <a href="http://example.com/login/">login</a> to view this post.</p>

                    </div>
                    
        <?php } // Closes if-block that checks post age ?>    
        </div> <!-- closes 'post class' -->

    <?php endwhile; else: ?>

        <p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>

    </div> <!-- closes 'content' -->


As Eduan mentioned, you can also incorporate s2Member Advanced Conditionals.

For example, my code above simply checks if the visitor is logged in (is_user_logged_in()) and then lets them view the page. If you wanted to only let people with s2Member Membership Level #2 or higher to see the post, you could change that to current_user_can("access_s2member_level2").

You could also incorporate checking for specific Custom Capabilities that you've assigned the user (see WP-Admin -> s2Member -> API / Scripting -> Custom Capabilities (Packages)).

Statistics: Posted by Raam Dev — November 14th, 2011, 10:37 pm


]]>
2011-11-14T10:41:31-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15899&p=52962#p52962 <![CDATA[Re: Membership only for older posts]]> http://www.s2member.com/advanced-conditionals-video/

And you can sell access with levels, so level 0 (free) has access to newer posts and level 1 has access to everything.
Check this video on how to do that:
http://www.s2member.com/general-options-overview-video/

I found all these videos in this link:
http://www.s2member.com/videos/

Statistics: Posted by Eduan — November 14th, 2011, 10:41 am


]]>
2011-11-14T10:11:07-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15899&p=52960#p52960 <![CDATA[Membership only for older posts]]>
Is it possible to setup S2 in way that you have to be a member to see posts of say older than one month. The newest posts must always be free for every visitor. Or will that require some extra (source)coding?

Thanks
Ron

Statistics: Posted by ronhen — November 14th, 2011, 10:11 am


]]>