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 Drip Paid Registration Time

Home Forums Community Forum Content Drip Paid Registration Time

This topic contains 7 replies, has 3 voices. Last updated by  Kyle Nash 4 years, 3 months ago.

Topic Author Topic
Posted: Sunday Sep 23rd, 2012 at 11:44 pm #26256
Kyle Nash
Username: CALicense

I’m using the following content dripping code on my site:


<?php /* Timestamp at Level #2, or `0` if they've NOT yet paid for Level #2. */
            $level2_payment_time =  s2member_paid_registration_time("level2"); ?>
   
   <?php if($level2_payment_time && $level2_payment_time <= ($_1_days_ago = strtotime("-1 days"))){ ?>

<p style="text-align: center">This exam is now available. Click <a title="Exam 2" href="http://calicenserenewal.com/exam/exam-section-2/">here</a> to take the exam.</p>

<?php } ?>

The “level2” is not being recognized though and the function is using the timestamp for the initial registration time, regardless of what level I specify within the parentheses in s2member_paid_registration_time(“level2”).

I need to drip content to users 24 hours after registering at level 2 and level 3 but this code is currently giving them access within 24 hours of initial registration.

Please let me know what I need to change to make this work.

Thanks,

Kyle

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Monday Sep 24th, 2012 at 1:26 am #26259
David Welch
Username: dwbiz05

Are you sure that this is pulling the registration timestamp?

What do you get when you echo $level2_payment_time?

Not trying to make you feel silly just trying to get all the info to help trouble shoot. The reason I ask is because if they have not paid, it would return a 0… which is less than the timestamp of 1 day ago. Which means it would show the content.

You’ve tested this on with a different user’s account that is at that specific level or has paid for it?

Dave

Posted: Monday Sep 24th, 2012 at 12:04 pm #26321
Kyle Nash
Username: CALicense

Hi Dave,

Yep when I echo $level2_payment_time I get the the timestamp of the initial registration.

And yeah I tested it with a user account that was initially set up 30 days ago but just moved to Level 2 about an hour before I was testing it. When I set the function to

<?php if($level2_payment_time && $level2_payment_time  <= ($_35_days_ago = strtotime("-35 days"))){ ?>

the dripped content was not displayed, but the content was still displayed when it was set to

<?php if($level2_payment_time && $level2_payment_time <= ($_1_days_ago = strtotime("-1 days"))){ ?>

Any ideas?

Thanks for your help.

Posted: Tuesday Sep 25th, 2012 at 12:29 am #26389
Raam Dev
Username: Raam
Staff Member

I recommend echoing $_35_days_ago (or $_1_days_ago) along with $level2_payment_time so that you can check the conditional yourself and see why it’s failing or not working the way you’re expecting.

Posted: Tuesday Sep 25th, 2012 at 12:42 pm #26451
Kyle Nash
Username: CALicense

$_35_days_ago and $_1_days_ago echo accurately.

$level2_payment_time and $level3_payment_time are echoing the initial registration time, not the registration time at level 2 and level 3.

This is the wp_s2member_paid_registration_times data in mysql for the test user I’ve been using:

a:3:{s:5:”level”;s:10:”1346198456″;s:6:”level1″;s:10:”1346198456″;s:6:”level2″;s:10:”1348455350″;}

With this data, I believe $level2_payment_time should echo 1348455350 and $level3_payment_time should echo 0, since the user has not yet registered at level 3.

Both variables are echoing 1346198456, which is the initial registration time (same as level 1 payment time).

What am I missing here?

Posted: Wednesday Sep 26th, 2012 at 4:13 am #26523
Raam Dev
Username: Raam
Staff Member

As per the docs in Dashboard -› s2Member® -› API / Scripting -› PHP/API Constants for S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME:

This holds the recorded time at which the Member originally registered their Username (or upgraded for) any type of “paid” access to your site. This value is preserved for the lifetime of their account, even if they upgrade, and even if they’re demoted at some point. Once this value is recorded, it never changes under any circumstance.

So, an upgrade to Level 2 would not change that date.

I’m not sure if there even is a timestamp that reflects the last upgrade to a paid level. I’ll consult with another support rep and get back to you. Thank you for your patience.

Posted: Wednesday Sep 26th, 2012 at 11:42 am #26577
David Welch
Username: dwbiz05

All paid registration times for each level are stored in the same user meta variable called “wp_s2member_paid_registration_times”. This is a serialized array of all registration times for that user.

That function you are using should be working. If not, try this one. It should call the same info being called by that function:

<?php
//Get level paid reg time

function dw_paid_level_time($level=1,$user_id=S2MEMBER_CURRENT_USER_ID){

	$time = get_user_meta($user_id,'wp_s2member_paid_registration_times',true); //gets usermeta data
	
	if(isset($time['level'.$level])){
		return $time['level'.$level]; //returns timestamp of designated level
	}
	else {
		return 0; //returns 0 if not found.
	}
}
?>

Call the above function like this:

<?php $level_1_reg_time = dw_paid_level_time(1); //attributes call level number first then user_id if not current user. ?>

Hope that helps,

Dave

  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 26th, 2012 at 11:55 pm #26643
Kyle Nash
Username: CALicense

Yep that worked! Thanks a ton!

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