This code recipe creates affiliates or updates the status of existing affiliates based on their membership level when using AffiliateWP.
The affiliate is created after their membership level is changed to the appropriate level (in the recipe, this is level ID 1). When membership is cancelled or expires, the affiliate’s status is changed to “inactive”.
The Code Recipe
Copy and paste this code recipe into a helper PMPro Customizations plugin.
Customize the level ID for your unique setup. You can set specific data about the affiliate by adding additional keys to the functions affwp_add_affiliate
and affwp_update_affiliate
.
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.