Created
February 19, 2020 16:06
-
-
Save ronalfy/64e19be55314f3baf028ce77a6f97df8 to your computer and use it in GitHub Desktop.
Limit Shown Posts with Paid Memberships Pro Series Add On
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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