Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Last active October 5, 2023 08:02
Show Gist options
  • Save dparker1005/d88e422c576587c473c9bb42b1bb8817 to your computer and use it in GitHub Desktop.
Save dparker1005/d88e422c576587c473c9bb42b1bb8817 to your computer and use it in GitHub Desktop.
Changes startdates that are retrieved for members. Useful for implementing custom content drip schedules when using the PMPro Series Add On.
<?php
// Copy from below here...
/**
* Changes startdates that are retrieved for members. Useful for implementing custom
* content drip schedules when using the PMPro Series Add On.
*
* @param string $startdate in a timestamp format.
* @param int $user_id to get startdate for.
* @param int $level_id to get startdate for ('0' if not specified)
* @return string
*/
function my_pmpros_customize_series_delay( $startdate, $user_id, $level_id ) {
/*
* To have posts unlock at midnight each day...
*/
// $startdate = strtotime( 'today', $startdate );
/*
* To have posts unlock at 10:00 each morning...
*/
// $startdate = strtotime( 'today 10:00', $startdate );
/*
* To have posts unlock on a certain days of the week. Note that
* post delay should be set to the number of days past last Monday to unlock.
* For example, if you want posts to unock on fridays, their delays should be
* 0 (to give access immediately), 4, 11, 18, etc...
*/
// $startdate = strtotime( 'last Monday', $startdate );
// or if you want to delay from next Monday...
// $startdate = strtotime( 'next Monday', $startdate );
/*
* To set a specific date for the post to unlock. Note that post
* delay should be set to the number of days past 2020/01/01
* that the post should unlock...
*/
// $startdate = strtotime( '2020-01-01 00:00:00');
return strval( $startdate );
}
add_filter( 'pmpro_member_startdate', 'my_pmpros_customize_series_delay', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment