Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Limit Shown Posts with Paid Memberships Pro Series Add On
<?php
/**
* CLimit Shown Posts with Paid Memberships Pro Series Add On
* Follow this guide to add this code to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
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