Plugin Planet

Premium WordPress Plugins

Learn how to add a custom checkbox fields to any USP Form.

Step 1: Use the following code for your Custom Field definition:

field#input_checkbox|checkboxes#Option 1:Option 2:Option 3|checkboxes_checked#Option 1|desc#My Label

Step 2: Add the custom-field shortcode to your form, for example:

[usp_custom_field form="123" id="1"]

That’s all there is to it. Here is a screenshot of the checkbox fields we just built:

USP Pro - Checkbox Fields

Note: To see a live example of a custom checkbox field, check out the “Starter” form demo, included in USP Pro version 2.3 and better (visit USP Forms > “Starter Form Demo”).

Attributes

Here are the attributes available for custom checkbox fields:

  • field – specifies the type of custom field
  • checkboxes – list of checkbox fields
  • checkboxes_checked – list of checkbox fields that should be checked by default
  • checkboxes_req – list of checkboxes that should be required (applies when not using multiple)
  • data-required – when set as true requires at least one checkbox to be selected (applies when using multiple)
  • multiple – use multiple#multiple to make the checkboxes an array (all checkboxes have same name)
  • desc – adds a description/label to the group of checkboxes

View more custom-field attributes »

Examples

Here are some example copy/paste recipes that you can use for different types of custom checkbox fields.

Each checkbox has a unique name, all required:

field#input_checkbox|checkboxes#input1:input2:input3|checkboxes_checked#input1|checkboxes_req#input1:input2:input3

All checkboxes have the same name, at least one checkbox is required:

field#input_checkbox|checkboxes#input1:input2:input3|checkboxes_checked#input1|multiple#multiple

Each checkbox has a unique name, none required:

field#input_checkbox|checkboxes#input1:input2:input3|checkboxes_checked#input1|data-required#false

All checkboxes have the same name, none required:

field#input_checkbox|checkboxes#input1:input2:input3|checkboxes_checked#input1|multiple#multiple|data-required#false

View more custom-field attributes »

Custom Custom Fields

Using Custom Custom Fields enables you to use your own names for the checkbox values.

By default, checkbox values look like this:

  • usp-custom-input1
  • usp-custom-input2
  • usp-custom-input3

..where input1, input2, and input3 correspond to the checkbox values defined in the custom-field definition, for example: checkboxes#input1:input2:input3. So if you need to use your own checkbox values, say, something like this:

  • books
  • movies
  • music

You can add these values to Advanced > “Custom Custom Fields” and then define your checkbox values accordingly:

checkboxes#books:movies:music

The only other thing you need to do is add one of the custom-field values as the field’s name attribute, for example:

name#books|field#input_checkbox|checkboxes#books:movies:music

Adding the name attribute is used only to tell USP to use your custom values instead of the defaults.

Notes

For checkbox fields that do not include multiple#multiple in the custom-field definition, the value of the name attribute can be any of the checkbox values. Totally doesn’t matter which one is used.

For checkbox fields that do include multiple#multiple in the custom-field definition, the value of the name attribute is used for the field value. In this case, the values of the checkbox fields would look like this:

  • books[books]
  • books[movies]
  • books[music]

..and the submitted custom-field names and values would look like this:

  • booksbooks
  • booksmovies
  • booksmusic

So it is the value of the name attribute in the custom-field definition that determines the custom-field name, and the value of each checkbox that determines the custom-field value.

Related