Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created February 19, 2020 16:06
Show Gist options
  • Save ronalfy/64e19be55314f3baf028ce77a6f97df8 to your computer and use it in GitHub Desktop.
Save ronalfy/64e19be55314f3baf028ce77a6f97df8 to your computer and use it in GitHub Desktop.
Limit Shown Posts with Paid Memberships Pro Series Add On
<?php
function my_pmpro_series_limit_posts_shown( $post_list, $series_object ) {
if ( ! is_user_logged_in() ) {
return $post_list;
}
global $current_user;
$member_days = pmpro_getMemberDays( $current_user->ID );
$posts_to_display = array();
foreach ( $post_list as $sp ) {
$posts_to_display[] = $sp;
if ( max( 0, $member_days ) < $sp->delay ) {
break;
}
}
return $posts_to_display;
}
add_filter( 'pmpro_series_post_list_posts', 'my_pmpro_series_limit_posts_shown', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment