Created
November 23, 2018 09:31
-
-
Save andrewlimaza/e8c29d047ba6e7dcbe4a8261c7e8404b to your computer and use it in GitHub Desktop.
Give access to specific membership level for PMPro Series posts.
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 | |
/** | |
* Give "All Access" to PMPro Series for specific membership level. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function open_series_to_specific_level($hasaccess, $thepost, $theuser, $post_membership_levels) { | |
// Bail if the user already has access to a post/page. | |
if ( $hasaccess ) { | |
return $hasaccess; | |
} | |
if ( pmpro_hasMembershipLevel( 1 ) && $thepost->post_type == 'pmpro_series' ) { // Change level ID to match levels for all access. | |
$hasaccess = true; | |
} | |
return $hasaccess; | |
} | |
add_filter("pmpro_has_membership_access_filter", "open_series_to_specific_level", 10, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment