Depending on your membership site, you may want to keep older content reserved for the members who were already around when you published it. This is a common need for serial content, private communities, or any site that wants to reward long-time members instead of handing new signups the whole backlog at once.

This code recipe hides member-only posts and pages published before a member’s join date, so new members can only see content released after they sign up.

Featured Image for Hide Previous Content From New Members

Do You Need This Recipe?

This recipe is a good fit if:

  • You restrict some or all of your content to paying members and want new members to grow into your archive over time instead of seeing everything at once.
  • You run a private community or resource library where older content should stay reserved for members who were around when they were published.
  • You want to reward long-time members by keeping part of your historical content exclusive to them.

The PMPro’s Series Add On works differently. It drip-feeds a curated sequence of content on a schedule based on days since a member joined, no matter when that content was published.

This recipe compares dates instead of counting days. It checks each protected post’s publish date against the member’s join date. Anything published before someone joined stays hidden from them automatically, with no manual scheduling required.

Use the Series Add On for a structured onboarding sequence or course-style drip. Use this code recipe to lock your existing archive away from new members automatically.

About the Code Recipe

Normally, PMPro lets a member view any post or page assigned to their membership level, no matter when it was published. This code recipe overrides PMPro’s default access rules by using the pmpro_has_membership_access_filter hook.

Every time PMPro checks access, the pmpro_has_membership_access_filter hook passes along the current access decision, the post being viewed, the user requesting access, and the membership levels the content requires. This code recipe’s my_pmpro_hide_old_posts_from_members() function receives those details and checks whether the content was published after the member joined.

If the content was published after, then it returns true and allows access. If it was published earlier, the function returns false and blocks access. It also swaps in a custom message explaining why the content is restricted with the pmpro_no_access_message_body hook.

Note: Pages and posts that require a membership level are still hidden from non-members entirely, regardless of publish date. This recipe only changes the experience for members who already have access to the level a post requires.

A Paid Memberships Pro post restricted because it was published before the member’s join date.

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

  • Change the message members see when they are blocked from older content: Edit the 'This content was published before your membership started.' string returned by my_pmpro_swap_old_posts_member_text() on line 48.


Was this article helpful?
YesNo

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