How to prefill fields

User experience is critical to your form conversions. With Kali Forms you can improve the submission process by requesting the minimum number of fields from your users. This is done by prefilling form fields with information that is already available.

You can prefill fields using URL parameters, the syntax is:

https://domain-name.com/form-page/?field-name=prefill-value

For example if you are using the basic contact form available in the plugin at the following page:

https://domain-name.com/contact/

… and you want to prefill the name field you only need to add ?name=John%20Doe to the URL:

https://domain-name.com/contact/?name=John%20Doe

If you are wondering what the %20 represents, this is the encoded version of an empty space. Since you cannot add spaces or other special characters in your URL, you must encode these characters using a percent sign and the hexadecimal value assigned to the character in the ISO-Latin character set. A space is assigned number 32, which is 20 in hexadecimal.

This can also be applied for dropdowns, radio and checkbox fields, the only difference is when you want to select multiple options in a checkbox field. In this case the syntax is a little different:

https://domain-name.com/form-page/?checkbox-group[]=first-value&checkbox-group[]=second-value

The first parameter that you add to your URL needs to use ? while the rest of your parameters will use &.


Another method for prefilling fields is through additional parameters in the Kali Forms shortcode. The basic syntax of the shortcode is:

[ kaliform id="your-form-id" ]

… in order to automatically prefill your form fields you will need to add extra parameters with the desired value. You will need to use the actual field names as the parameters.

[ kaliform id="your-form-id" first-name="John" last-name="Doe"]

For multiple choice fields you will need to set each value separated by a comma:

[ kaliform id="your-form-id" first-name="John" last-name="Doe" checkbox-group="first-value,second-value" ]

If the user is already logged in on your site and you wish to display the user information directly in the form fields you can use the following set of placeholders.

  • {first_name} – this will return the first name of the logged in user.
  • {last_name} – this will return the last name of the logged in user.
  • {user_email} – this will return the email address of the logged in user.
  • {display_name} – this will return the selected display name for the logged in user.
  • {user_url} – this will display the website of the logged in user
  • {user_login} – this will return the username of the logged in user
Was this article helpful to you? Yes No 1

Still stuck? We’re here to help.

Send us a message and we’ll get back to you as soon as we can.