Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active February 4, 2025 06:57
Show Gist options
  • Save andrewlimaza/823ddff62b8aedafc4d4d6663ab9f695 to your computer and use it in GitHub Desktop.
Save andrewlimaza/823ddff62b8aedafc4d4d6663ab9f695 to your computer and use it in GitHub Desktop.
Allow admins, administrator, administrators access to all restricted posts in WordPress with Paid Memberships Pro
<?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);
@ikishorkumar
Copy link

@andrewlimaza
Copy link
Author

This is no longer needed, with the latest version of PMPro you can dynamically adjust this from the toolbar while viewing a post/frontend.

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