Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created October 23, 2020 17:11
Show Gist options
  • Save ronalfy/171f6afe113512de25f0ff72df90bfce to your computer and use it in GitHub Desktop.
Save ronalfy/171f6afe113512de25f0ff72df90bfce to your computer and use it in GitHub Desktop.
PMPro - Allow Access to Specific Feeds
<?php
/**
* Allow PMPro access to a specific feed.
* Ref: https://gist.github.com/ocean90/4973288
*
* 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/
*/
/**
* Check if in a specific feed and allow access.
*/
function my_pmpro_has_feed_access( $hasaccess, $mypost, $myuser, $post_membership_levels ) {
$custom_feed = 'custom';
if ( is_feed( $custom_feed ) ) {
return true;
}
return $hasaccess;
}
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_has_feed_access', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment