Filter

WordPress Filters are ways to modify data at runtime. In most cases, filters are used to modify data before it is sent to the database or the browser. Filters are part of the WordPress plugin API and are used extensively by WordPress core, themes, and plugins.

Bricksforge comes with a few filters that you can use to modify the output of the plugin.

Form Filters

bricksforge/pro_forms/allowed_file_types

This filter allows you to modify the allowed file types for a form. The filter passes the allowed file types as an array.

add_filter( 'bricksforge/pro_forms/allowed_file_types', function( $allowed_file_types ) {
    $allowed_file_types[] = 'pdf';
    return $allowed_file_types;
} );

bricksforge/pro_forms/max_file_size

This filter allows you to modify the maximum file size for a form. The filter passes the maximum file size in bytes.

add_filter( 'bricksforge/pro_forms/max_file_size', function( $max_file_size ) {
    $max_file_size = 1024 * 1024 * 10; // 10 MB
    return $max_file_size;
} );

bricksforge/pro_forms/repeater_depth

This filter allows you to modify the maximum repeater depth for all form actions which support repeaters. The filter passes the maximum repeater depth as an integer.

add_filter( 'bricksforge/pro_forms/repeater_depth', function( $repeater_depth ) {
    return 5;
} );

bricksforge/pro_forms/datepicker_options

This filter allows you to modify the datepicker options for a form. The filter passes the datepicker options as an array. Important This filter is only working for the β€œDate” element for Nestable Pro Forms. If using the legacy form building approach of Pro Forms, use bricks/element/form/datepicker_options instead.

add_filter( 'bricksforge/pro_forms/datepicker_options', function( $datepicker_options ) {
    $datepicker_options['locale'] = [
        'firstDayOfWeek' => 1 // Set Monday as the first week day
    ];

    return $datepicker_options;
} );

bricksforge/pro_forms/validate

This filter allows you to validate a form submission. The filter passes the validation result, the form data, the post ID, and the form ID. To stop the form submission, you can return false and send an error message using wp_send_json_error.

add_filter( 'bricksforge/pro_forms/validate', function( $validation_result, $form_data, $post_id, $form_id ) {
    if ( empty( $form_data['form-field-email'] ) ) {
        wp_send_json_error([
            "message" => "Email is required",
        ]);
        
        return false;
    }

    return $validation_result;
}, 10, 4 );

Email Designer Filters

bricksforge/email_designer/allowed_vars

With this filter, you can add your custom Twig Variables. The filter passes the allowed variables as an array.

add_filter( 'bricksforge/email_designer/allowed_vars', function( $allowed_vars ) {
    $allowed_vars['custom_var'] = 'Custom Variable';
    return $allowed_vars;
} );

After adding your custom variable, you can use it in your email templates like this:

{{ custom_var }}