Skip to main content

tripetto_prefill filter

📖 Description

This filter is invoked when a form is shown. It can be used to prefill/prepopulate the fields of a form. In most cases, you can include this hook in the functions.php file of your WordPress theme using the add_filter WordPress function.


The prefill filter uses the Import.fields function for importing the values into the form.


Make sure to specify the correct number of arguments for the 4th parameter accepted_args of the add_filter function. The number given there must match the number of parameters your filter function has!


add_filter("tripetto_prefill", function($values, $form, $language) {
// Add values to the $values array here

return $values;
}, 10, 3);


$valuesarrayNoEmpty PHP array that can be used to add values that should be prefilled. To specify the data for a certain field there are two options:
- Use the alias of a field (the alias of a question block can be set in the form builder);
- Use the key (identifier) of a field.
See the example below for more information.
$formobjectYesPHP JSON object with form information. Contains the following fields:
- id: Contains the id of the form (number);
- reference: Contains the reference of the form (string);
- name: Contains the name of the form (string);
- fingerprint: Contains the fingerprint of the form (string);
- runner: Contains the name of the runner used for the form (string);
- created: Contains the date the form was created (string);
- modified: Contains the last modified date of the form (string).
$languagestringYesContains the current user locale.


In the following example, we prefill a question using the alias of a question. In this case, a text input field with the alias NAME is set for the form with name Example form (aliases are set in the form builder):

add_filter("tripetto_prefill", function($values, $form) {
if ($form->name === "Example form") {
// Supply a value for the form field with alias `NAME`
array_push($values, array(
"name" => "NAME",
"value" => "Test"

return $values;
}, 10, 2);

But, you can also reference a field by its key identifier:

add_filter("tripetto_prefill", function($values, $form) {
// Supply a value for the field with the specified key
array_push($values, array(
"key" => "9ef64ab160ef6096ceecb4561f3eecc37007b669337929393a9d3789fa744f3e",
"value" => "Test"

return $values;
}, 10, 2);