How to request custom people fields on webpages

This HOWTO assumes you understand the complexity of using custom fields and have already created custom people fields. While custom people fields can be requested on most action pages, custom donation fields can only be requested on donation pages.


Pages where custom people fields can be requested

Custom people fields can be requested on the following 10 action pages:

  1. Signup
  2. Donation
  3. Endorsement
  4. Event
  5. Feedback
  6. Invoices (within the invoice payment form only)
  7. Moneybomb
  8. Petition
  9. Survey (on the signup portion, not individual questions)
  10. Volunteer Signup

Please note: The example snippets below are formatted for use on a signup page and are styled for V2 Themes. To include these custom fields on non-Signup action pages, please use the example snippets provided for the following pagetypes:


Liquid to request all custom people fields

The following code will request all custom people fields from your nation on a signup page:


Liquid to request individual custom people fields

The Liquid code needed for each custom people field type is listed here:
Field type Liquid code
text {% text_field "signup.custom_values.slug" %}
number {% text_field "signup.custom_values.slug" %}
check box {% check_box "signup.custom_values.slug" %}
multiple choice {% collection_select "signup.custom_values.slug", custom_fields.signup.slug.multiple_choice_options %}

Please note: The "signup." prefix before "custom_values" is not required on signup pages and should be removed.

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 display individual custom people fields

Custom people field values can be displayed using the "custom_values_for_display" Liquid variable. For example, the following will return all of the custom field values for the current user of the page:

{{ request.current_signup.custom_values_for_display }}

It's also possible to display a specific custom field by scoping the output to its associated slug:

{{ request.current_signup.custom_values_for_display['custom_field_slug'] }}

If you'd like to display custom fields on a user's profile page, you'll want to use the 'profile.' prefix:

{{ profile.custom_values_for_display['custom_field_slug'] }}

If you'd like to display custom fields in an email, you'll want to use the 'recipient.' prefix:

{{ recipient.custom_values_for_display['custom_field_slug'] }}

If you'd like to display custom fields in a custom walk sheet, you'll want to use the 'signup.' prefix:

{{ signup.custom_values_for_display['custom_field_slug'] }}


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.