Some sites need to offer a specific enrollment period, perhaps for a specific session of a class or other training event.

This recipe allows you to set a specific window of time for membership registration. Users will not be able to checkout for the level after your specified cutoff date.

Featured image for code recipe on offering a membership level for a limited time

Understanding the pmpro_registration_checks filter

The pmpro_registration_checks filter hook in Paid Memberships Pro allows you to customize the default registration validation logic, determining whether a user is allowed to complete registration for a membership.

Functions hooked to this filter can return true to allow registration to proceed, or false to prevent it.

About the Code Recipe

This code recipe uses the pmpro_registration_checks filter to add a validation step during checkout that checks whether the membership registration cutoff date has already passed.

If the cutoff date has passed:

  • Registration will be blocked.
  •  A message is shown to the user informing them that registration has ended.
  • The membership level’s settings are updated to disallow future signups.
  • The level is removed from display on the “Membership Levels” page.

Existing members of the level will retain access for the duration of their membership term.

To reopen registration later, remove this code recipe from your site and uncheck “Disable New Signups” on the Memberships > Settings > Levels > Edit admin dashboard page.

Message shown to user that memberships are no longer available after a certain 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 Recipe

Update line 18 with the ID of your limited time membership level and line 19 with the date the membership stops being offered (in YYYY/MM/DD format).

You can find your level’s ID on the Memberships > Settings > Levels screen in the WordPress admin dashboard.

Pro tip: You can use this code recipe along with the Sitewide Sales plugin to add a temporary banner that lets visitors to your site know about the limited availability of this membership level.

Video: Coding with Sam Walkthrough

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