Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
@Pietjo
Copy link

Pietjo commented Feb 5, 2020

I have tried the suggested code via the Paid Membership Pro plugin. As a result, I could not log into my site. I got the following message"

"Parse error: syntax error, unexpected '<', expecting end of file in /home/customer/www/imalipro.com/public_html/wp-content/plugins/pmpro-customizations/pmpro-customizations.php on line 12
There has been a critical error on your website. Please check your site admin email inbox for instructions."

After I removed the snippet I could log into the site again.
Is there somebody with advice to rectify this problem?

@andrewlimaza
Copy link
Author

andrewlimaza commented Feb 5, 2020

@Pietjo please don’t copy the opening PHP tag on line 1

@Pietjo
Copy link

Pietjo commented Feb 5, 2020

Thanks, Andrew

@andrewlimaza
Copy link
Author

andrewlimaza commented Feb 5, 2020

You're welcome :)

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