Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/948841d83aa2ed655f1ed9722591034f to your computer and use it in GitHub Desktop.
Save andrewlimaza/948841d83aa2ed655f1ed9722591034f to your computer and use it in GitHub Desktop.
Give access to membership for all restricted posts.
<?php
/**
* Give access to all members regardless if they have access to the current post or not.
* Add this code to your PMPro Customizations - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function give_access_to_all_pmpro_members_example( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
if ( pmpro_hasMembershipLevel( array( 7, 8, 9, 10 ) ) ) {
$hasaccess = true;
}
return $hasaccess;
}
add_filter( "pmpro_has_membership_access_filter", "give_access_to_all_pmpro_members_example", 10, 4 );
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Unlock Membership Access to All Restricted Content Without Updating Posts" at Paid Memberships Pro here: https://www.paidmembershipspro.com/allow-membership-levels-access-all-restricted-posts/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment