Forked from andrewlimaza/pmpro_allow_access_for_admins.php
Created
August 13, 2020 13:58
-
-
Save femiyb/71ddfccd3b4db395643db6800e1eff32 to your computer and use it in GitHub Desktop.
Allow admins access to all restricted posts in WordPress with Paid Memberships Pro
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 | |
| /** | |
| * This code snippet allows admins without any PMPro membership level to access any restricted content. | |
| * Add this code to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function pmmpro_allow_access_for_admins($hasaccess, $mypost, $myuser, $post_membership_levels){ | |
| //If user is an admin allow access. | |
| if( current_user_can( 'manage_options' ) ){ | |
| $hasaccess = true; | |
| } | |
| return $hasaccess; | |
| } | |
| add_filter('pmpro_has_membership_access_filter', 'pmmpro_allow_access_for_admins', 30, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment