Easy Digital Downloads is an ecommerce plugin to sell digital products like eBooks, software, PDF files and more. Because EDD has subscription features, you might think that the plugin isn’t compatible with PMPro. But, you actually can use both PMPro and EDD together.
In this guide we’ll show you one way that sites are combining these two plugins: giving customers a membership level after their EDD purchase is completed. The code recipe below connects EDD download purchases to membership levels in PMPro. After checkout, your customers gain immediate access to protected content and any other benefits of their assigned level.
Table of contents
Understanding the Code
The provided PHP code snippet lets you automatically assign a membership level based on the purchase of a specific EDD product. This relationship is achieved by mapping the EDD product IDs to corresponding membership levels in PMPro.
How Membership Level <> EDD Product Mapping Works:
- Product ID to Membership Level Mapping: Each EDD product is assigned an ID, and this ID is linked to a specific membership level. When a product is purchased, the script reads the product ID from the transaction details and assigns the user the corresponding membership level.
- Options for Customization: You can also set up more complex mappings that include custom membership attributes, like expiration dates or billing cycles, for each product.
This mapping ensures that once a customer completes a purchase, they are automatically granted access to membership-restricted content, streamlining the process of content access based on user transactions.
About the Code Recipe
By adding this code to your site, you can:
- Ensure only paying customers access certain content.
- Enhance user engagement by providing instant benefits post-purchase.
- Streamline the membership assignment process using automated scripts.
Update the $product_levels
array in the script with your specific product and membership level mappings. Ensure that customers create accounts during checkout as this script requires user accounts to function properly.
See this guide from EDD on creating user accounts at checkout.
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.
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.