Just like categories and tags help you organize your WordPress site’s posts, a user taxonomy helps your organize your WordPress site’s users.
User taxonomies store all kinds of structured data about your members—any field that has a specific set of options can be stored in a user taxonomy.
In v2.9 of Paid Memberships Pro, we introduced an interactive settings page to create user profile fields. With a variety of popular field types, this feature is an evolution of our Register Helper Add On, which only supported adding fields via custom code.
But there’s still a lot you can do with custom coded fields that our settings page doesn’t offer. This tutorial demonstrates how to create a custom User Taxonomy field for membership checkout and profiles.
User Taxonomies and Custom Fields
Using custom code, membership sites can register a custom WordPress user taxonomy field and capture structured data about their members on the checkout form or on a member’s user profile page. Here’s an email of four unique taxonomies, captured as a dropdown, multi-select, radio, and checkbox field type.
Much like the native Post Categories or Post Tags in WordPress, Data captured in a taxonomy is automatically stored as a WordPress term.
To configure a custom user taxonomy and add it to your forms requires two functions in PMPro: pmpro_add_user_taxonomy
and pmpro_add_user_field
.
The recipe below demonstrates how to first register four unique user taxonomies. You can use any of these field types to capture and display a user taxonomy profile field.
In this recipe, I’ll show you how to add a select, multi-select, radio, and checkbox list field type. Each of these fields allow users to select from the structured list of terms you’ve defined.
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.
Populate Terms for Your User Taxonomy
After configuring this code, navigate to Users > Your Taxonomy Name in the WordPress admin. Just like the Posts > Categories screen, this page allows you to insert as many new term names for the taxonomy as you’d like.
Whenever a field is shown to a user or admin, the user fields code in PMPro automatically shows every term you’ve created.
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.