This code recipe demonstrates how to automatically set the Paid Memberships Pro – Addon Packages price for a specific content when restricting that content to a particular membership level.
This feature helps to streamline the process of creating restricted content and ensures that any new restricted content that you create has the correct Addon Packages price.
Getting Started
This code recipe will not overwrite an Addon Package price if there is already one set for a particular piece of content. As a result, if there is content that you would like to modify the “Require Membership” settings for without automatically setting an Addon Packages price, you can specify the price of the content as “0” to prevent it from being automatically updated.
Once the code recipe has been added to your website change “15” on line 11 of the code recipe to the price that you would like to automatically set for your addon packages On your website, edit a piece of content that you would like to restrict, select a checkbox in the “Require Membership” settings box, and see that the price for the content has been filled with the price specified in step 2.
NOTE: This code recipe will only restrict content when one of the “Require Membership” checkboxes is toggled. If your content is being restricted in other ways (for example, by category), it will still be necessary to update the price of each piece of content manually. For the same reason, content will not be restricted retroactively by this code recipe.
David Parker is the Lead Developer at Paid Memberships Pro, where he plays a critical role in shaping the core plugin and its Add Ons. His work includes contributing code, reviewing pull requests, and managing releases to ensure the software meets the evolving needs of membership site owners.
David finds fulfillment in supporting small businesses and nonprofits, helping them thrive through membership solutions. He enjoys tackling the complex technical challenges that come with building and maintaining robust membership tools.
Outside of work, David enjoys spending time with his wife and puppy, often taking walks or visiting the dog park. He’s also recently developed an interest in disc golf, adding a new hobby to his free time activities.
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.