Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ronalfy/7bab6f3c9930d6995e42793807203cd8 to your computer and use it in GitHub Desktop.
Save ronalfy/7bab6f3c9930d6995e42793807203cd8 to your computer and use it in GitHub Desktop.
PMPro - Allow Post Authors to Access Membership Content
<?php
/**
* Allow authors to access their own protected blog posts.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_allow_authors_access( $has_access, $post, $user, $levels ) {
if ( current_user_can( 'edit_post', $post->ID ) ) {
return true;
}
return $has_access;
}
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_allow_authors_access', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment