-
-
Save travislima/919853f5bcb10b1027ca9cc2ace6cf92 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 | |
/** | |
* 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