Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created November 23, 2018 09:31
Show Gist options
  • Save andrewlimaza/e8c29d047ba6e7dcbe4a8261c7e8404b to your computer and use it in GitHub Desktop.
Save andrewlimaza/e8c29d047ba6e7dcbe4a8261c7e8404b to your computer and use it in GitHub Desktop.
Give access to specific membership level for PMPro Series posts.
<?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