How to request and display custom people fields on public profiles

Custom people fields can be requested on the account settings screen (signups_edit.html) and displayed on public profiles (profiles_show.html, profiles_show_wide.html) much like they can be on webpages.

This HOWTO assumes you understand the complexity of using custom fields and have already created custom people fields.

To include other fields on public profiles, please reference our profile liquid variables page.


Liquid to display custom people fields on public profiles

It is possible to display all of a user's custom people fields on their public profile as a complete list:

{{ profile.custom_values_for_display }}

Or to display each field individually by its slug:

{{ profile.custom_values_for_display['custom_field_slug' }}

Liquid to request individual custom people fields

Code for requesting custom people fields should be placed after the {% form_for signup, html: { :multipart: true } %} call found in the signups_edit.html template.

slug refers to the 'slug' of the custom people field in question.


Field type Liquid code
text slug
{% text_field "custom_values.slug" %}
number slug
{% number_field "custom_values.slug" %}
check box slug
slug
multiple choice slug
{% collection_select "custom_values.slug", custom_fields.signup.slug.multiple_choice_options %}

To make a text or number field required, you can add the HTML5 required attribute, as follows:
{% text_field "signup.custom_values.slug", required: "required" %}


Liquid to request all custom people fields

The following code will request all custom people fields from your nation on the account settings page:


Request only one type of custom people field

It is possible to request only custom people text fields.

Show code to request only text fields.

It is possible to request only custom people number fields.

Show code to request only number fields.

It is possible to request only people multiple choice fields, which includes yes/no fields.

Show code to request multiple choice fields.

It is possible to request only custom people true / false fields.

Show code to request only true / fales fields.


Limiting the number of custom people fields requested

Using the liquid limit and offset filters, you can easily control how many fields of a certain type are called to the page the code is placed on. Add the phrase "limit:#" and "offset:#" to the 'forloop' you're using to call the custom fields.

Limit the number of custom donation fields requested using the limit filter. The order of the fields requested is determined by the order they are listed in Settings > Defaults > Custom fields > People. You can skip fields and not request them by using the offsetting filter. The request begins at a different point than the first listed field (e.g. offset:1 begins requesting fields after skipping 1 field, offset:2 would skip 2 fields, etc).

Request the first 2 custom people fields.

Show code to request only the first 2 custom people fields.

Request only the first 4 custom people number fields

Show code to request only the first 4 number fields.


Limiting the custom people fields requested based on field slug

You can use a conditional "if" statement to check if the slug of the custom field contains a specific word:

Request custom people fields with the word "shirt_size" in the slug:

Show code to request fields with "shirt_size" in slug.


How to create custom people fields

Introduction to custom fields

How to create custom donation fields

How to request custom donation fields on donation pages

Liquid variables available in email

If you’re unclear on how this feature works, please ask a question. If you would like to see changes to this feature, please submit a suggestion.