Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travislima/919853f5bcb10b1027ca9cc2ace6cf92 to your computer and use it in GitHub Desktop.
Save travislima/919853f5bcb10b1027ca9cc2ace6cf92 to your computer and use it in GitHub Desktop.
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