This recipe adds a checkbox field at Membership Checkout which allows members to subscribe to multiple membership levels in a single checkout process.

Users can select to opt-in to additional levels by checking a box on the membership checkout form. After completing checkout, the chosen levels are added to their base membership.

Assign Levels at Checkout via Checkbox Fields Code Recipe Banner Image

About the Code Recipe

This code recipe is designed to add a checkbox to let any user add a level ID 2 membership as an option at checkout, in addition to the base membership level they have chosen to purchase.

The code recipe includes two separate functions:

  1. The first function adds the checkbox field labeled “Include Level 2 Content?”. The user’s selection is stored in user meta just like any custom user profile field.
  2. The second function extends how the user field is stored via a custom save_function for user fields. In this function, the membership level is added to the user (at no additional charge) if they have selected the box at checkout.

The best way to understand the usefulness of this code is through an example. Let’s say you offer a paid premium membership level with several protected categories of content. You could certainly give everyone all of the content, but that won’t give you much in terms of member analytic data.

With this code, you can offer additional protected categories of content as bonus selections on the user’s default membership. These categories are free to join for anyone with another active paid level.

At checkout, this code gives users the option to add on additional categories (linked to free membership levels) to include with their premium membership. With this approach, you as the admin get better visibility into which members are choosing to add which content. You can filter your members list by users that chose to add on each additional content type (level).

Membership Level Checkout with Additional Options to Include Level 2 Content

This method also means that you can leverage all the features of our email marketing integrations for subscriber tagging as well as advanced automations where the user’s membership level is used to check access.

Members can adjust their preferences and “added levels” on the frontend Member Profile Edit screen.

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.

Adjust the level IDs throughout the recipe for your needs. In this code, the level that gets added is ID 2. This ID is set in several places within the recipe and user field unique name.

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?