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.

Content dripping by date (calender date)

Home Forums Community Forum Content dripping by date (calender date)

This topic contains 9 replies, has 3 voices. Last updated by  Bruce 4 years ago.

Topic Author Topic
Posted: Friday Nov 23rd, 2012 at 8:06 am #32408

Hi, I am very interested in this plugin. I am also thinking about upgrading to the paid version, but first I need to know something about content dripping. I have posted this subject already in the free forum – but I did not get any reply for quite awhile. I can not continue, if I do not know/understand, if it will work out. So please answer my question. Everything else within the plugin so far works for me. I now really need to know if this part with content dripping also works, as I need it…

I already made parts of what I want work with this code from your examples in the plugin and here: http://www.s2member.com/kb/intro-content-dripping-in-s2member/

// If the user has been paid for your site for at least 30 days

<?php if(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 30){ ?>
	Drip content to Members that started paying you at least 30 days ago.
<?php } ?>

I just want to have it a little different. This is what I want:

Instead of couting all 24 hours, it should drip the new content always after midnight, regardless of what time the user first has logged on. Right now as a new user comes into the system he is getting a time stamp:

Fri Nov 2nd, 2012 @ precisely 5:56 pm
In my example the user will get a new video page with content each and every day for 28 days. But as it is now, if I take the example from above the user enters at about 6 pm and watches day one and then the next day he wants to watch part two, he right now has to wait until 6 pm again, before seeing the new content.

BUT: I want it, so that with the NEW DATE (right after midnight), the new content is available. So that fixed to each calender date the user can see exactly one individual piece of content each and every single calender day, regardless of the time he first became a member.

How can I achieve this? Many regards, still testing, but I am really excited by this piece of software.

Looking foward to your answer,
Arnegger

List Of Topic Replies

Viewing 9 replies - 1 through 9 (of 9 total)
Author Replies
Author Replies
Posted: Friday Nov 23rd, 2012 at 2:31 pm #32442
Raam Dev
Username: Raam
Staff Member

First we need to get midnight on the day the user paid:

$midnight_paid_registration_time = strtotime('today', S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);

The timestamp recorded in $midnight_paid_registration_time will be in Unixtime format, so to figure out if 1 day has passed since that time, you’ll need to add 86400 seconds to the timestamp (there are 86400 seconds in a day). If you want to figure out if 2 days have passed, you need to add 172800 seconds (86400 x 2), and so on.

So here’s how the code might look:

<?php 
// midnight Unix Timestamp on the day the user paid
$midnight_paid_registration_time = strtotime('today', S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);

// Unix Timestamp right now 
$now = time();
?>

<?php if($midnight_paid_registration_time + 86400 < $now){ ?>
	Drip content to Members that started paying you at least 1 day ago
<?php } ?>

<?php if($midnight_paid_registration_time + 172800 < $now){ ?>
	Drip content to Members that started paying you at least 2 days ago
<?php } ?>

<?php if($midnight_paid_registration_time + 259200 < $now){ ?>
	Drip content to Members that started paying you at least 3 days ago
<?php } ?>
Posted: Friday Nov 23rd, 2012 at 8:01 pm #32456

OK great. I got to try this out. Another question that I have is regarding the Links. When I have a link link from outside: Let’s say I use content dripping and I want to have users every day to login and read their daily piece of content. I then would setup a autoresponder sending an email a day reminding the member by sending him a link to the speciffic daily piece of content. BUT: As the user clicks that link he comes automatically to the content protection window and has to login. After the login the user comes automatically to the in GENERAL OPTIONS under LOGIN WELCOME PAGE defined start page after login. How can I change this, so the user will be forward automatically to the in the email clicked link?

Best Regards,
Arne

Posted: Monday Nov 26th, 2012 at 3:23 pm #32621
Raam Dev
Username: Raam
Staff Member

When someone is redirected to the Membership Options Page (Dashboard -› s2Member® -› General Options -› Membership Options Page), there are several variables that are passed to that page (see Dashboard -› s2Member® -› API / Scripting -› Membership Options Page Variables (MOP Vars)). You can use those to determine which page the user should be redirected to after login.

Using those variables, you can use some PHP code on your Membership Optons Page to redirect from the Membership Options Page to the login page along with a special redirect_to query string variable that points to the original page the user was trying to access. This way, as soon as the user logs in, WordPress will redirect them to that page they were trying to access.

This code will go on the Membership Options Page. You will need to be running a plugin like the Exec-PHP Plugin so that you can execute PHP code inside a WordPress page.

<?php 
if (isset($_GET['s2member_seeking'])) {
	$page_seeking = $_GET['s2member_seeking'];
	$page_seeking_id = substr($page_seeking, strpos($page_seeking, '-') + 1, strlen($page_seeking) - strpos($page_seeking, '-'));
	$redirect_to_page = urlencode(get_permalink($page_seeking_id));
	$redirect_url = wp_login_url( $redirect_to_page );
	echo '<meta http-equiv="refresh" content="1; url='. $redirect_url . '">'; 
	echo "<p>You must be logged in to access this area.</p>";
	echo "<p>Redirecting to the login page...</p>";
} else { ?>

Regular Membership Options Page content goes here. It will be seen by anyone who visits this directly, i.e., they were not redirected to the Membership Options Page because they were trying to access protected content without access.

<?php } ?>
Posted: Wednesday Nov 28th, 2012 at 12:58 pm #32791

Okay – thank you. I’ll try that. Regarding the content dripping I also need to know: Is it possible to use content dripping in a way that it starts not from the date the user was set up, but from when the user first logged in?

I tried the API Scripting section in s2Member and guess it should be there if something like this would exist. But since I did not find it, I thought maybe you could give me a hint, if something like this exists?

Regards, Arnegger

Posted: Wednesday Nov 28th, 2012 at 4:34 pm #32819
Raam Dev
Username: Raam
Staff Member

Hi Arnegger,

The first login date is not something that’s captured by s2Member or WordPress, however you could write a hack that records the first login date somewhere and then read that value from within your Content Dripping conditionals. See this thread for more ideas on how you can capture the login date.

Posted: Monday Dec 3rd, 2012 at 8:54 pm #33401

— 1st subject: REDIRECTION from your post #32621 —

I have now checked out the code in your post #32621 regarding the redirection after login. It seem to ALMOST work … very close. But I cannot figure out the real problem. Everything works fine, but after entering the login information (I also need to say I use the “Theme my login” Plugin … however right after I am logging in I get redirected to the URL:

http://domainname.com/login/http%3A%2F%2Fdomainname.com%2Fweek4%2Fday24-marketing%2F

So for some reason it puts the http:// PLUS domainname/login in front of your brilliant redirection. I guess everything else would be working and I would get redirected to the correct page. I tried different things, but as I am not a programmer, I could not figure it out, why I did not make it work. What is the mistake I can not find in the code – and how would be the right code?

— 2nd subject: CONTENT DRIPPING BY DATE from your post: #32442 —

Since I am really no programmer – just can read some php code and usually guess right what it means:
2.1) I guess in the first part we’re creating the variable: “$midnight_paid_registration_time = strtotime(‘today’, S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);” correct? Where do we do that? Just in the same post, right inside the php-Tag where the other code goes?

2.2) In the second part: How can I create out of the seconds -> DAYS again. There must be a way to convert this back into days, so I would be able to just enter days, to make it much more convenient… ?

Posted: Tuesday Dec 4th, 2012 at 6:12 pm #33484
Bruce
Username: Bruce
Staff Member

Hi Arnegger,

Regarding your first question:

It appears that the plugin you are using changes the value of the wp_login_url() to /login. Try changing wp_login_url( $redirect_to_page ) to '/wp-login.php?redirect_to=' . $redirect_to_page;

2.1) I guess in the first part we’re creating the variable: “$midnight_paid_registration_time = strtotime(‘today’, S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);” correct? Where do we do that? Just in the same post, right inside the php-Tag where the other code goes?

This goes in the same post, at the top, right along with all of the other processes going along with it. You could simply copy the exact code that Raam has given you and put it into a post/page (assuming you have a PHP Execution plugin installed.)

2.2) In the second part: How can I create out of the seconds -> DAYS again. There must be a way to convert this back into days, so I would be able to just enter days, to make it much more convenient… ?

Certainly. Just divide the variables by 86400 (for the seconds in a day):

<?php 
// midnight Unix Timestamp on the day the user paid
$midnight_paid_registration_time = strtotime('today', S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);

// Unix Timestamp right now 
$now = time() / 86400;
$midnight_paid_registration_time = $midnight_paid_registration_time / 86400;
?>

<?php if($midnight_paid_registration_time + 1 < $now){ ?>
	Drip content to Members that started paying you at least 1 day ago
<?php } ?>

<?php if($midnight_paid_registration_time + 2 < $now){ ?>
	Drip content to Members that started paying you at least 2 days ago
<?php } ?>

<?php if($midnight_paid_registration_time + 3 < $now){ ?>
	Drip content to Members that started paying you at least 3 days ago
<?php } ?>
Posted: Wednesday Dec 12th, 2012 at 5:25 am #34335

Dear Raam or Bruce,

thank you for your explanation. I have tried creating this code for me – but I did not get it to work. My guess is that I really do not know where I would have to implement the $midnight_paid_registration_time and creating the Unix-Timestamp.

Would this be working if I put it like this in the each post? -> In other words: Do I put all of this (what there is below) into each individual post? So for the post of the first day it would be… ALL OF THIS CODE???:

<?php 
// midnight Unix Timestamp on the day the user paid
$midnight_paid_registration_time = strtotime('today', S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);

// Unix Timestamp right now
$now = time() / 86400;
$midnight_paid_registration_time = $midnight_paid_registration_time / 86400;
?>

<?php if($midnight_paid_registration_time + 1 < $now){ ?>
	Drip content to Members that started paying you at least 1 day ago
<?php } ?>

….OR JUST THE DRIPPING CONTENT PART – BUT THEN WHERE WOULD I HAVE TO PUT THE FIRST PART WITH THE TIMESTAMP, OF THIS CODE?

I am sorry – I am no programmer, as you may tell. I just know the very, very basics of writing code. If I do not get it to work:
How much would it cost to get one of you to write me this short lines of code so I could implement it for the “Content dripping by date” question? Is there a possiblilty to have this finished this way? I have setup everything already and would love to have it run with s2Member and I do not want to change or try other membership plugins, but stay with s2Member. Do you think it would be possible you help me there to get this running?

Very warm christmas season greetings,
Arnegger

Posted: Wednesday Dec 12th, 2012 at 3:03 pm #34409
Bruce
Username: Bruce
Staff Member

Would this be working if I put it like this in the each post? -> In other words: Do I put all of this (what there is below) into each individual post? So for the post of the first day it would be… ALL OF THIS CODE???:

Yes that’s correct. That code *should* work as-is.

How much would it cost to get one of you to write me this short lines of code so I could implement it for the “Content dripping by date” question? Is there a possiblilty to have this finished this way? I have setup everything already and would love to have it run with s2Member and I do not want to change or try other membership plugins, but stay with s2Member. Do you think it would be possible you help me there to get this running?

I’d recommend posting this on jobs.wordpress.net, or elance.com if you don’t feel comfortable continuing. I believe some of the team is on there as well.

Viewing 9 replies - 1 through 9 (of 9 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.