Last active
January 16, 2019 14:59
-
-
Save kimcoleman/16868cadce280415073b3d8812b56a91 to your computer and use it in GitHub Desktop.
Filter the output of the Series post list to exclude posts the current user cannot access.
This file contains hidden or 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 | |
/* | |
* Filter the output of the Series post list to exclude posts the current user cannot access. | |
*/ | |
function hide_noaccess_posts_pmpro_series( $post_list_posts, $series ) { | |
if ( function_exists( 'pmpro_has_membership_access' ) ) { | |
foreach ( $post_list_posts as $key => $sp ) { | |
$hasaccess = pmpro_has_membership_access( $sp->id, NULL, false ); | |
if ( empty( $hasaccess ) ) { | |
unset( $post_list_posts[ $key ] ); | |
} | |
} | |
} | |
return $post_list_posts; | |
} | |
add_filter( 'pmpro_series_post_list_posts', 'hide_noaccess_posts_pmpro_series', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment