By default, Paid Memberships Pro uses the the_content filter to hide member content from non-members. When a non-member lands on a piece of restricted content, they are shown a message as set under Memberships > Advanced Settings.

This recipe shows you how to redirect away from members-only content. It’s a useful approach if you want to completely hide the existence of the post or for theme or plugin conflicts.

Banner for Advanced Code Recipe Tutorial for Paid Memberships Pro

About the Recipe

Some themes (especially video/image/media-based themes) don’t display the main content through the the_content function. For these kinds of pages/themes, you can edit your theme to wrap sensitive bits using the pmpro_hasMembershipLevel() function or you can simply redirect non-members from the page entirely. We also have another tutorial that covers some known theme or page-builder conflicts that may be useful in your troubleshooting.

The Code Recipe

We are considering making this an option in the plugin settings, but for now you can redirect non-members away from member content using the code below.

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.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo