latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Membership Access Restrictions

Home Forums Community Forum Membership Access Restrictions

This topic contains 5 replies, has 3 voices. Last updated by  Cristián Lávaque 4 years, 4 months ago.

Topic Author Topic
Posted: Tuesday Sep 4th, 2012 at 4:56 pm #24066

Hello,

I am wanting to restrict my Level #1 members so that they cannot open posts older than their registration date. How do I get that set up?

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Tuesday Sep 4th, 2012 at 9:35 pm #24105
Raam Dev
Username: Raam
Staff Member

Hi Cheryl,

This is an advanced modification and will require using PHP code to check the user’s registration date and compare that to the date of the post.

You’ll need to modify your theme’s single.php file and add the necessary conditional using PHP.

To retrieve the user’s registration date, you can use the s2Member S2MEMBER_CURRENT_USER_REGISTRATION_TIME PHP constant (see Dashboard -› s2Member® -› API / Scripting -› PHP/API Constants). To retrieve the post date, you’ll need to use the WordPress the_date() function.

Since the_date() returns the post date in a different format (human readable) from what S2MEMBER_CURRENT_USER_REGISTRATION_TIME is returned in (Unixtime), you’ll first need to convert the_date() to Unixtime using the PHP strtotime() function.

So, the conditional might look something like this:

<?php
	if ( strtotime( the_date() ) < S2MEMBER_CURRENT_USER_REGISTRATION_TIME ) {
		// show post
	} else {
		// show message informing user they don't have access to older posts
	}
?>

If you’re not comfortable with PHP and need help implementing this advanced modification to your WordPress theme, we recommend posting a job on jobs.wordpress.net.

Posted: Tuesday Sep 4th, 2012 at 11:23 pm #24118

Hey, that’s perfect! Thanks for the code snippet. That should work perfectly for what I need!
I thought it would be something close to that effect., but didn’t know the exact syntax!

Thanks for your help!

Posted: Friday Sep 7th, 2012 at 1:58 am #24463
Raam Dev
Username: Raam
Staff Member

You’re most welcome, Cheryl! :)

Posted: Saturday Sep 8th, 2012 at 2:14 pm #24656

I have another question on this subject. The code previous worked like a charm and is working fine.

But now the issue that I’m seeing is that S2member doesn’t restrict the browsers ability to copy and paste protected content. Which isn’t a big deal, I found a different plugin that will do that. But I cannot find anything that will block Safari’s ability to “mail contents of the page” feature. Since alot of our content is paid content, is there anyway we can keep users from emailing all that content to others?

Just curious if you knew of a way….

I’ve scowered the web and have come up clueless.

Thanks for your help! You guys have a great product here!

Posted: Monday Sep 10th, 2012 at 7:18 am #24731

No, s2Member doesn’t restrict those actions, just loading the page or not. What happens in the browser after that is not something s2Member restricts. And even if you did restrict it with JavaScript, it’d be easily bypassed disabling JavaScript. :/

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.