This page provides documentation on supported field types in the PMPro User Fields settings page and API.

The most common field types and customization requirements are available via the settings page. Developers can explore our documentation on coding fields for more complex needs, such as custom field saving functions, storing fields in a user taxonomies, or pre-populating field dropdowns with custom data arrays.

All Available Field Types

These are the field types supported in the User Fields API.

Field Types Supported Through Custom Code Only

At this time, the User Fields settings page in the WordPress admin does not support these field types. You must use custom code to add these fields:

Field Options For All Field Types

Option NameDescriptionParameters (default)
namename attribute of the field. This will override the name previously set when declaring the PMProRH_Field object. Must start with a letter and not include any spaces or special characters other than _.user_meta key
id*Custom id attribute for the field.string
addmember*If the PMPro Add Member Admin plugin is activated, this field will also show up in the form under Memberships –> Add Member.bool (false)
classCustom class attribute for the field.string
requiredMake this field required.bool (false)
labelCustom <label> for the field or ‘false’ to hide the label. If not specified, the name will be used.string
levels*Show this field only for certain levels. Takes either a single membership level ID or an array of membership level IDs.

Fields created through the settings page automatically inherit this attribute from the group settings.
int or array
memberslistcsv*Show this field on the CSV export when using the “Export to CSV” feature on the Members List page in the WordPress dashboard.

This field is automatically set to true for fields created through the settings page.
bool (false)
readonlyMake this field read-only (uneditable).bool (false)
depends*Make this field dependent on another field. See Conditional Fields.array
profileShould this field also be shown in the member profile when a user is logged into their account? Valid values are false, true, “admin”, “only”, or “only_admin”.
  • Use false to hide the field from the user profile page when a member is logged into their account.
  • Use true to show the field on the profile page for both users and admins.
  • Use admin to show the field on the profile page to admins only.
  • Use only to show the field only on the profile page to users when they are logged into their accounts and admins. The field will not be shown at checkout.
  • Use only_admin to show the field only on the profile page for admins. The field will not be shown at checkout. Users will not see the field in the admin when they are logged into their accounts.
Fields created through the settings page can inherit this attribute from the group settings.
mixed (true)
showrequired*Show the asterisk(*) next to the field if it is required.bool (true)
showmainlabel*Show the <label> for the field.bool (true)
divclassCustom class attribute for the field’s containing <div> element.string
hintDisplay a hint under the field.string
html_attributes*Additional HTML attributes to be included in the field output (i.e. ‘placeholder’).array
save_function*A custom function that adjusts how the value is saved. Read this article for an example method of using the attribute.string

Note: These fields are only available when using custom code and cannot be set using the User Fields settings screen.

Note: If you are using BuddyPress and our BuddyPress Integration you can sync profile fields with xProfile fields using the buddypress option.

Specific Field Options by Type

text

The “text” field type will generate an <input type="text"> field.

Option NameDescriptionParameters (default)
sizesize attribute of <input> fieldint
valuepre-populate a field’s value if not set for the current userstring (optional)

textarea

The “textarea” field type will generate a <textarea></textarea> field.

Option NameDescriptionParameters (default)
rowsrows attribute of <textarea> fieldint (5)
colscols attribute of <textarea> fieldint (80)

select, select2, and multiselect

The “select” field type will generate a <select></select> field. The “select2” field type will generate a multi-select field with autocomplete. A multiselect field will show a list of options in a fixed height field. This field requires an array of options with the format array('option_value' => 'Option Label'). A default “blank” option can be added by passing a blank option value.

Option NameDescriptionParameters (default)
optionsArray of <option></option> elements as described above.array
multipleAdd the multiple attribute, allowing multiple options to be selected at once. Has no effect with “select2” or “multiselect” field types.bool (false)

checkbox

The “checkbox” field type will generate an <input type="checkbox"> field. If the “text” option is not provided, the main label will be next to the checkbox. If the “text” option is provided, a separate, additional label will be shown next to the checkbox.

Option NameDescriptionParameters (default)
textCustom <label></label> for the checkbox.string

checkbox_grouped

The “checkbox_grouped” field type is more like a select/dropdown type than a checkbox. It will generate a grouped list of multiple checkbox options. Requires an array of options with the format array('option_value' => 'Option Label'). Unlike the select and select2 fields, this field type is multiselect by default and cannot be made to choose just one value.

Option NameDescriptionParameters (default)
optionsArray of <option></option> elements as described above.array

radio

The “radio” field type will generate an <input type="radio"> field. It requires an array of options with the format array('option_value' => 'Option Label').

Option NameDescriptionParameters (default)
optionsArray of <option></option> elements as described above.array

file

The “file” field type will generate an <input type="file"> field. By default, uploaded files are saved to the “wp-content/uploads/pmpro-register-helper/user_login/” directory.

Option NameDescriptionParameters (default)
acceptAdd the accept attribute.string
previewWhether to display a preview of file (image-type fields only).bool (false)
allow_deleteOption to allow users to delete their uploaded file. Valid values are false, true, or “only_admin” (default). Use false to disallow file deletion. Use true to allow users and admins to delete files. Use only_admin to only allow file deletion for admins only.mixed (only_admin)

html

The “html” field type will generate any HTML you wish. The name attribute of any element within the given HTML will be used for the field’s value.

This field type is intended for including HTML elements on the page, eg. headers, horizontal Lines, images, etc.

Option NameDescriptionParameters (default)
htmlThe custom HTML code to display for the field.string

number

The “number” field type will generate an <input> field that has a toggle to increment or decrement the value of the field.


date

The “date” field type will generate with a dropdown option for the month field and then text input fields for the day and a 4-digit year value. Optionally specify the “value” attribute to pre-populate a field’s value if not set for the current user.

A date value will be recorded even when the user does not complete the date fields. To require a date to be entered by the user, use this snippet:


hidden

The “hidden” field type will generate an <input type="hidden"> field. Optionally specify the “value” attribute to pre-populate a field’s value if not set for the current user.


readonly

The “readonly” field type will show just the value of the $field. Optionally specify the “value” attribute to pre-populate a field’s value if not set for the current user.


Conditional Fields

Any registered field can be dynamically hidden or shown with JavaScript depending on another field’s value. To create a conditional field, pass an array of conditions as the depends option. The depends array should contain an array of conditions formatted like array(array('id' => {field_name}, 'value' => {field_value}))

Read our full guide on conditional field logic with User Fields »

Was this article helpful?
YesNo