Skip to content

Instantly share code, notes, and snippets.

@dwanjuki
Created April 9, 2026 09:26
Show Gist options
  • Select an option

  • Save dwanjuki/cfb8f5e6414611bb7d20f9152fcfe685 to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/cfb8f5e6414611bb7d20f9152fcfe685 to your computer and use it in GitHub Desktop.
Posts with specified tags will not require membership to view
<?php
/**
* Posts with specified tags will not require membership to view
*
* 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_open_tag_posts_to_all_visitors( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
// if PMPro says true already, return true
if ( $hasaccess ) {
return $hasaccess;
}
// Posts with these tags will be accessible to everyone
$tags = array( 'free-tag' );
if ( has_tag( $tags, $thepost ) ) {
$hasaccess = true;
}
return $hasaccess;
}
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_open_tag_posts_to_all_visitors', 20, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment