Custom User Profile Fields allows you to unlock more possibilities in Paid Memberships Pro. By default, user field settings allow you to specify a single field type for custom fields. But what if you want to specify a different field type based on the user’s role? 

Change User Profile Field Type Based on User Role Recipe Banner Image

About the Code Recipe

This code recipe will allow you to change field types based on the role of the user.

The example below creates a text field for site admins and displays a read-only custom field to members.

Frontend Readonly User Field Profile on PMPro

This recipe gives administrators the ability to enter in a value for the respective custom field. Members are only be able to view the custom field without having the ability to edit any data.

Other Applications

One can also use this code recipe with our Generate a Unique Member Number for Display on Membership Account, Confirmation Email and More article.

For example, administrators will be able to create a unique membership number for their members, without having to worry about their members changing this number.

Admin Editable User Field

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.

If you’re more comfortable using the User Fields settings page to add your fields, you could do this without code. In that case, create two separate field groups, one that shows for admins only and one that shows for users.

  • In the admin group, add a field with the exact name member_number that’s a text field type.
  • In the user profiles only group, add a field with the exact name member_number that’s a readonly field type.

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?