By default, the Limit Post Views Add On for Paid Memberships Pro restricts access to posts after a non-member has viewed their specific number of posts. However, in some use cases, you may want to always restrict access to some posts unless the visitor is a logged-in member, regardless of the free post views limit you have set for non-members.
This guide shows you how to enforce a stricter content restriction by hiding these posts from non-members immediately, ensuring the PMPro protected content message is displayed on these posts, prompting the visitor to sign up for a membership on your site.

Understanding the Code Recipe
This code uses the pmprolpv_has_membership_access
filter to override the default post view logic, allowing developers to choose to grant or deny free views to specific posts.
About the Code Recipe
This code recipe ensures the restricted posts remain inaccessible to non-members who should have free views.
Before implementing this code recipe:
- You must have configured the Limit Post Views Add On for non-members.
- Replace
100, 101, 102
on line 24 with the ID of your specific posts on your website.
The Code Recipe
Adding the Recipe to Your Website
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.
How to Customize This Code Recipe
You can also enhance the member experience by displaying a custom message or redirecting non-members to a login or signup page when they attempt to view a restricted post. Here is how you can extend its functionality:
- To redirect non-members when accessing specific posts, use the
template_redirect
action to check if the current post ID is in your restricted list and the visitor does not have a membership. If both conditions are true, usewp_redirect()
to send them to a custom URL. - To display a custom message on restricted posts, use the
pmpro_no_access_message_body
filter to check if the current post is in your restricted list, then return a styled HTML block with your custom message and links to log in or join.