Some membership sites want to restrict signups to specific members who have been pre-approved to join. One practical way to do this is to require a discount code at checkout: members who receive the code can complete their purchase, and everyone else is blocked from proceeding.
This post includes two code recipes. The first targets a single membership level by ID. The second applies the same restriction to every level that belongs to a particular level group. Both use the pmpro_registration_checks filter to block checkout when no discount code is present.
Possible Use Cases
There are a few reasons you would want to restrict who can join a membership level. Common scenarios include:
- VIP Membership: Use this recipe if you have a VIP level for select users only, or if you have members paying offline and want to give them access to create their account after payment is received.
- Adjusting the Price Per Member: Create a custom price for each member based on a personal exchange. After setting the price for that member, create a unique discount code that adjusts the level price to their rate and email it to them. The member can then complete checkout and pay their adjusted amount.
- Hiding Your Membership Pricing on the Frontend: Some sites remove their membership options from public view entirely. In this model, a contact form or inquiry link replaces the levels page, and prospective members receive an access code after expressing interest.
If you need to generate a large number of unique codes that all share the same pricing, see the Group Discount Codes Add On.
Or, for a more robust pre-approval workflow, see the Approval Process for Membership Add On.

About the Code Recipes
Both recipes hook into pmpro_registration_checks, a filter that runs when a member attempts to complete checkout. The callback checks whether a discount code was entered and returns false with an error message if the field is empty. The member cannot proceed until they supply a valid code.
The difference between the two recipes is what they check:
- Recipe 1 targets a single level by its ID.
- Recipe 2 uses
pmpro_get_group_id_for_level()to determine which group the level being purchased belongs to, then applies the restriction to every level in that group.

The Code Recipes
Recipe 1: Require a Discount Code for a Specific Level
This recipe blocks checkout for a specific membership level unless the member has entered a discount code. By default, it checks for level ID 1. Update that value to match the level you want to restrict.
How to Customize This Code Recipe
- Update the level ID in the conditional on
line 24to match the membership level you want to restrict. You can find level IDs on the Memberships > Settings > Levels screen in the WordPress admin. - To require a specific discount code rather than any code, replace the conditional with the commented-out alternative in the snippet on line 31 (remove
line 24and replace it withline 31). UpdateREQUIRED_CODEto your exact discount code name. - To restrict multiple levels, swap the equality check for an
in_array()check:in_array( $pmpro_level->id, array( 1, 2, 3 ) ).
Recipe 2: Require a Discount Code for Any Level in a Level Group
If your site uses PMPro’s level groups to organize levels that are public and others that require permissions, the second recipe is for you. This recipe applies the discount code requirement to every level that belongs to a specified group. Set $required_group_id to the ID of the group you want to restrict.
How to Customize This Code Recipe
- Update
$required_group_idonline 29to the ID of the level group you want to restrict. You can find a group’s ID on the Memberships > Settings > Levels screen in the WordPress admin. Each group is in its own collapsible section. The group ID shown to the right of the group’s name. - To restrict multiple groups, replace the single ID comparison with an
in_array()check:in_array( $group_id, array( 2, 3 ) ). - To require a specific discount code rather than any code, add a string comparison after the empty check in
line 43:trim( strtoupper( $discount_code ) ) !== 'REQUIRED_CODE'.
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.
More Ways to Restrict User Registrations
Check out these additional tutorials with more ways to restrict user registration:
- Restrict Certain Words in Usernames
- Exclude Certain Email Domains from Membership Signup
- Limit the Number of Members by Membership Level
- Offer a Membership Level for a Limited Time
- Restrict Checkout for Users with a History of Refunds
- Restrict Membership Signup by Country
- Restrict Membership Signup by Email Domain
- Require a Discount Code to Checkout for a Certain Level
- Restrict Membership Checkout by Email or Username


