Fluent Forms hooks & filters cheatsheet

tdrayson

Fluent Forms has lots and lots of hooks and filters. I have found the most useful and common hooks and filters and put them into a big list with examples and use cases for people to quickly find and reference.

fluentform_insert_response_data

This hook is used to modify the data from your form before it is saved to the database.

Some use cases could be:

  • Pulling data dynamically from elsewhere in your website like custom fields
  • Adding or subtracting information entered
  • Calculating date of birth

Essentially anything that needs to be done server side, and you don’t want to be cached.

PHP

        <?php

add_filter('fluentform_insert_response_data', 'tct_my_function', 10, 3);

function tct_my_function($formData, $formId, $inputConfigs)
{
   if($formId != 1) { // Replace with your Form ID
      return $formData;
   }

    $input_email = $formData['email']; // change 'email' with your input field name

    return $formData;
}
      
Copy

View all tutorials that use the fluentform_insert_response_data hook

View hook source

fluentform_rendering_field_data_{input_key}

This hook is used to modify the input data. This includes the actual input data and input settings.

Some use cases could be:

  • Dynamically populating a select dropdown with external data
  • Load ACF field data from the specific post
  • Generate a random code with a PHP snippet

You need to replace {input_key} with the field type that you want to use.

Field type examples:

  • input_text
  • input_number
  • select
  • email
  • address
PHP

        <?php 

add_filter('fluentform_rendering_field_data_input_text', 'tct_my_function', 10, 2);

function tct_my_function($data, $form)
{
    if($form->id != 1) {
        return;
    }

    // Check if our field is equal to my_text_field
    if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'my_text_field') {
        return $data;
    }



    return $data;
}
      
Copy

View all tutorials that use the fluentform_rendering_field_data hook

View hook source

Smartcodes

Smartcodes are used for dynamic data in the inputs default value

Smartcodes are made up of 2 hooks.

  • fluentform_editor_shortcodes – For form editor list
  • fluentform_all_editor_shortcodes – For Email/Confirmation Settings list
  • fluentform_shortcode_parser_callback_{smartcode_name} – Transforming your data

Some use cases could be:

  • Load ACF field data from the specific post
  • Generate a random code with a PHP snippet
  • Email confirmation data

You need to replace {smartcode_name} with the name of your smartcode.

PHP

        add_filter('fluentform_editor_shortcodes', function ($smartCodes) {
    $smartCodes[0]['shortcodes']['{my_own_smartcode}'] = 'My Own smartcode';
    return $smartCodes;
});

add_filter('fluentform_editor_shortcode_callback_my_own_smartcode', function ($value, $form) {
    $dynamicValue = $form->title; // Returns current form title. You can fetch any data and return it here.
    return $dynamicValue;
}, 10, 2);
      
Copy

View all tutorials that use the fluentform_all_editor_shortcodes hook

View hook source

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise