PMPro’s Sponsored Members Add On allows a member to purchase a block of linked accounts. When a primary “parent” member completes checkout, they receive a code to distribute to their team for use during registration.
When you start using this Add On for an existing membership site, the logic to generate sponsor codes only happens for new member checkouts based on your custom configuration.
If you would like existing members with a valid “parent” level to also receive a sponsor code, this is the code recipe you need.
The code recipe below allows you to auto-generate sponsor codes for existing members.
Table of contents
About the Code Recipe
This code recipe is useful for sites that want to begin using the features of Sponsored Members and have existing members that qualify for child accounts.
When an existing member logs in to your site, the code recipe checks whether or not the member meets the following criteria:
- They have a valid level that receives child accounts per your site’s $pmprosm_sponsored_account_levels setup code.
- They do not already have a sponsor code in their account.
If these conditions are met, the sponsor code will be automatically generated on the fly. (Note that this code recipe doesn’t create all the sponsor codes as a bulk process, it runs “on the fly” as the existing members log into your site).
The Code Recipe (PHP)
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.