Skip to main content

tripetto_styles filter

📖 Description

This filter can be used to modify the style settings for a form. This is useful if you want to set a fixed style for your forms so the form editors don't need to configure the style settings for each form they create. In most cases, you can include this hook in the functions.php file of your WordPress theme using the add_filter WordPress function.


This filter only works for forms that are loaded synchronously. This is the default loading mechanism for forms in the plugin, so this filter will work fine out-of-the-box. Asynchronous loading of forms is an optional setting that sometimes helps to speed up the loading time of a page that contains a form (especially when a large form is shown). When that setting is enabled, the tripetto_styles filter will not be invoked for 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_styles", function($styles, $form, $language) {
// Modify $styles here

return $styles;
}, 10, 3);


$stylesobjectNoPHP JSON object with the current styles for the form. The fields in this object depends on the type of runner that is used for the form. Have a look at the API reference of the runners for more details:
- Autoscroll runner styles
- Chat runner styles
- Classic runner styles
$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.


Set a fixed color for all forms:

add_filter("tripetto_styles", function($styles) {
$styles->color = "green";

return $styles;
}, 10, 1);

Or, add the $form parameter to filter for a specific form:

add_filter("tripetto_styles", function($styles, $form) {
if ($form->name === "Example form") {
$styles->color = "green";

return $styles;
}, 10, 2);