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™

restrict only older posts - based on age

s2Member Plugin. A Membership plugin for WordPress®.

restrict only older posts - based on age

Postby arthomas » May 11th, 2011, 4:59 pm

Hello guys

Is it possible to restrict posts based on age?

Case:
I want to offer news to everybody, but archives only to paid members, archives would be considered all posts older than 3 weeks or a month.
I think some newspapers have this model.

Is it currently possible? its not any particular date, just 3 weeks from today, or so.

I think its a very simple and interesting way to get people to pay while keeping your general readership happy.
User avatar
arthomas
Registered User
Registered User
 
Posts: 19
Joined: September 21, 2010

Re: restrict only older posts - based on age

Postby Cristián Lávaque » May 11th, 2011, 5:24 pm

Yeah, I agree it's an interesting way to doing it. :)

Well, you could use s2Member conditionals to check that the user is a paid member and check the time the post was published too, and show it based on that.

WP Admin -> s2Member -> API / Scripting
http://www.s2member.com/api-scripting-overview-video/
http://www.s2member.com/advanced-conditionals-video/
https://codex.wordpress.org/Template_Tags#Post_tags
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: restrict only older posts - based on age

Postby arthomas » May 11th, 2011, 5:34 pm

Thanks for your answer.
well :o
I am in no way well versed in PHP. this seems quite complicated.

Isn't there a simple way to do it?
Maybe it can be added to a future version. I guess its not a too obscure feature, probably many people will use it.

Or maybe you can give the right snippet of code.

Thanks anyway
User avatar
arthomas
Registered User
Registered User
 
Posts: 19
Joined: September 21, 2010

Re: restrict only older posts - based on age

Postby Cristián Lávaque » May 11th, 2011, 8:43 pm

I haven't tested it, but I think it'd be something like this:

Code: Select all
<?php // Paid member or post newer than 30 days: show.
if (current_user_can('access_s2member_level1') || (time() - get_the_time('U')) < 2592000) { ?>
    
    Here goes the post...

<?php } ?>


Of course you'd need to customize it further to present something different for those that can't see the post.

If you don't know enough PHP to achieve the customization you want, I suggest you get a freelance developer to help you at a place like jobs.wordpress.net, take a look here viewforum.php?f=37

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


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron