Table of Contents

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 page 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.

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:

01{% for cf in custom_fields.signup %}

02

03{% assign custom_field = cf[1] %}

04{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

05

06<div class="row-fluid">

07  <div class="span12">

08

09    {% if custom_field.is_text? or custom_field.is_number? %}

10    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

11    {% text_field custom_field_id, class:"text" %}

12

13    {% elsif custom_field.is_boolean? %}

14    <label class="checkbox" for="signup_custom_values_{{ custom_field.slug }}_custom">{% check_box custom_field_id, class:"checkbox" %} {{ custom_field.name }}</label>

15

16    {% elsif custom_field.is_multiple_choice? %}

17    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

18    {% collection_select custom_field_id, custom_fields.signup[custom_field.slug].multiple_choice_options, class:"select" %}

19    {% endif %}

20

21  </div>

22</div>

23

24{% endfor %}

Request only one type of custom people field

It is possible to request only custom people text fields.

01{% for cf in custom_fields.signup %}

02

03{% assign custom_field = cf[1] %}

04{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

05

06<div class="row-fluid">

07  <div class="span12">

08

09    {% if custom_field.is_text? %}

10    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

11    {% text_field custom_field_id, class:"text" %}

12    {% endif %}

13

14  </div>

15</div>

16

17{% endfor %}

It is possible to request only custom people number fields.

01{% for cf in custom_fields.signup %}

02

03{% assign custom_field = cf[1] %}

04{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

05

06<div class="row-fluid">

07  <div class="span12">

08

09    {% if custom_field.is_number? %}

10    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

11    {% text_field custom_field_id, class:"text" %}

12    {% endif %}

13

14  </div>

15</div>

16

17{% endfor %}

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

01{% for cf in custom_fields.signup %}

02

03{% assign custom_field = cf[1] %}

04{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

05

06<div class="row-fluid">

07  <div class="span12">

08

09    {% if custom_field.is_multiple_choice? %}

10    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

11    {% collection_select custom_field_id, custom_fields.signup[custom_field.slug].multiple_choice_options, class:"select" %}

12    {% endif %}

13

14  </div>

15</div>

16

17{% endfor %}

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

01{% for cf in custom_fields.signup %}

02

03{% assign custom_field = cf[1] %}

04{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

05

06<div class="row-fluid">

07  <div class="span12">

08

09    {% if custom_field.is_boolean? %}

10    <label class="checkbox" for="signup_custom_values_{{ custom_field.slug }}_custom">{% check_box custom_field_id, class:"checkbox" %} {{ custom_field.name }}</label>

11    {% endif %}

12

13  </div>

14</div>

15

16{% endfor %}

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.

01{% for cf in custom_fields.signup limit:2 %}

02<!-- limits output to 2 custom fields^^^ -->

03

04{% assign custom_field = cf[1] %}

05{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

06

07<div class="row-fluid">

08  <div class="span12">

09    {% if custom_field.is_text? %}

10    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

11    {% text_field custom_field_id, class:"text" %}

12    {% endif %}

13  </div>

14</div>

15{% endfor %}

Request only the first 4 custom people number fields.

01{% for cf in custom_fields.signup limit:4 %}

02<!-- limits output to 4 custom fields^^^-->

03

04{% assign custom_field = cf[1] %}

05{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

06

07<div class="row-fluid">

08  <div class="span12">

09

10    {% if custom_field.is_number? %}

11    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

12    {% text_field custom_field_id, class:"text" %}

13    {% endif %}

14

15  </div>

16</div>

17

18{% endfor %}

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:

01{% for cf in custom_fields.signup %}

02

03{% assign custom_field = cf[1] %}

04{% assign custom_field_id = 'custom_values.' | append: custom_field.slug %}

05

06{% if custom_field.slug contains "shirt_size" %}

07<!-- check for slug to contain "shirt_size" -->

08

09<div class="row-fluid">

10  <div class="span12">

11

12    {% if custom_field.is_text? %}

13    <label for="signup_custom_values_{{ custom_field.slug }}_custom">{{ custom_field.name }}</label>

14    {% text_field custom_field_id, class:"text" %}

15

16    {% endif %} <!-- end slug check -->

17

18  </div>

19</div>

20

21{% endif %}

22

23{% endfor %}

Related HOWTOs

How public profiles work
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

Did this answer your question?