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 based on Profile field

Home Forums Community Forum Content Dripping based on Profile field

This topic contains 3 replies, has 3 voices. Last updated by  Bruce 3 years, 11 months ago.

Topic Author Topic
Posted: Monday Jan 7th, 2013 at 8:41 am #36452

HI! Is it possible to drip content based on a date field in a member’s profile?

I have S2member registration/profile fields setup that includes a Course Start Date field that I set the default value of when enrolment opens. I’ve also turned on the BuddyPress integrations and this field is also sent to Mailchimp on registration (using mu-plugins/s2hacks.php).

I would like to drip the course content based on this date field. So my login welcome page will have something like:

if today is > StartDate
drip week 1 content
if today is > StartDate + 7
drip week 2 content
if today is > StartDate + 14
drip week 3 content

I’m trying to reduce the amount of manual work I have to do at the start of each course session. If I can just change the default course start date for new registrations and then everything flows through to their profile, Mailchimp and the content dripping that would be ideal.

Some more background – the course is run every 3 months, but students get access to the course materials for 1 year. The course content is dripped out over 2 months, but not all students finish in that time. I hope the scenario above will work so that new students only see the week they are up to, but students from previous sessions will be able to see all the content.

I hope that all makes sense!! thanks.

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Tuesday Jan 8th, 2013 at 4:45 pm #36613

Hi Michelle.

Yes, you can do that. Please see the documentation here: [hilite path]Dashboard -› s2Member® -› API / Scripting -› Content Dripping[/hilite]

I hope that helps. :)

Posted: Friday Jan 18th, 2013 at 6:27 am #38018

OK, I’m using this thread as a guide: http://www.s2member.com/forums/topic/content-dripping-by-date-calender-date-2/

I’ve got the code below, but it isn’t working. The only thing I’ve changed really is the source of the date from the registration date to the custom registration field STDATE = start date. What am I doing wrong??

<?php 
// midnight Unix Timestamp on the course start date
$user_start_date = get_user_field ("STDATE");
$midnight_stdate = strtotime('today', '$user_start_date');
// Unix Timestamp right now 
$now = time() / 86400;
$midnight_stdate = $midnight_stdate / 86400;
?>

<?php if($midnight_stdate + 7 < $now){ ?>
	Drip content for week 2 of course
<?php } ?>

<?php if($midnight_stdate + 14 < $now){ ?>
	Drip content for week 3 of course
<?php } ?>

<?php if($midnight_stdate + 21 < $now){ ?>
	Drip content for week 4 of course
<?php } ?>

I just want to drip new content, at midnight, once a week, after the course start date.

Thanks!

Posted: Sunday Jan 20th, 2013 at 4:40 pm #38482
Bruce
Username: Bruce
Staff Member

Thank-you for reporting this important issue.

The code within this forum post is meant to mimic the way that s2Member’s Content Dripping works. A content drip based on s2Member’s default start date (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS) would look like this:

<?php if(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 30){ ?>
	Drip content to Members that started paying you at least 30 days ago.
<?php } ?>
To use Content Dripping, or any PHP code within a WordPress Post/Page, you will need a plugin that allows you to execute PHP. Try PHP Execution.
For more information on Content Dripping with s2Member:

See: Knowledge Base » Introduction to Content Dripping in s2Member®
See Also: Dashboard -› s2Member® -› API / Scripting -› Content Dripping

To mimic s2Member’s Content Dripping, you first need to establish the start point for your new content dripping (Note: These are Unix timestamps. See: http://www.unixtimestamp.com/).

You can find info in this post regarding creating/updating s2Member’s Custom Profile/Registration Fields, if that is how you’d like to save your start time.

Example:
<?php
$start_date = get_user_field('STDATE'); //Note: This assumes that you've saved your Start Date in s2Member's Custom Registration/Profile Fields array, as STDATE. If you have not, you will need to change this.

$start = strtotime('today', $start_date);
&#91;/hilite&#93;

Now, to find the amount of time that has elapsed between the time that you have set up, and now, you will want to subtract the time now from the start time. Timestamps are based on seconds, so to find the number of days between, you'll need to divide the remaining time by &#91;hilite mono&#93;864900&#91;/hilite&#93; (&#91;hilite mono&#93;24 hours&#91;/hilite&#93; x &#91;hilite mono&#93;60 minutes&#91;/hilite&#93; x &#91;hilite mono&#93;60 seconds&#91;/hilite&#93;).

The previous post does this on the fly. For clarity, I've changed the way that this is handled below.

<h5>Example:</h5>

<?php $start_date = get_user_field('STDATE'); //Note: This assumes that you've saved your Start Date in s2Member's Custom Registration/Profile Fields array, as STDATE. If you have not, you will need to change this. $start = strtotime('today', $start_date); $now = time(); $time_to_check = ($now – $start)/86400; //Now, minus the start time, converted to days by dividing by 86400 &#91;/hilite&#93; The above uses the Custom Profile/Registration Field &#91;hilite code&#93;'STDATE'&#91;/hilite&#93; to assign the variable &#91;hilite code&#93;$time_to_check&#91;/hilite&#93; a value. This value can now be used in place of s2Member's &#91;hilite code&#93;S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS&#91;/hilite&#93; within the page that you have set this up with. <h5>Example of finished custom Content Drip:</h5>
<?php $start_date = get_user_field('STDATE'); //Note: This assumes that you've saved your Start Date in s2Member's Custom Registration/Profile Fields array, as STDATE. If you have not, you will need to change this. $start = strtotime('today', $start_date); $now = time(); $time_to_check = ($now – $start)/86400; //Now, minus the start time, converted to days by dividing by 86400 ?> <?php if($time_to_check >= 7){ ?> Drip content to Members that have spent at least 7 days on your site, after the custom field had been created. <?php } ?>

The above code snippet should work correctly for you. Let us know if problems persist.

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