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.

Automatically set price on Addon Packages

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.


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.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo