Skip to content
Front User Submit
Menu

Actions and filters

All PHP actions and filters of Front User Submit with parameters and examples, plus the JavaScript fe_hooks events.

This page lists the hooks of Front User Submit 5.2.0 with their parameters, taken from the code.

In the parameters below, $post_id is the string 'new' when a new post is being created. $all_form_settings is the array returned by BFE\Form::get_form_settings($form_id):

[
  'form_builder_json' => '…JSON of the fields…',
  'form_settings'     => [ /* fe_form_settings */ ],
]

Submit flow

When a user sends a form, POST /bfe/v1/add_or_update_post runs these hooks in this order:

  1. bfe_ajax_before_post_update_or_creation (action): validation
  2. bfe_ajax_before_front_editor_post_update_or_creation (filter): change $post_data
  3. The post is inserted or updated
  4. bfe_ajax_after_front_editor_post_inserted or bfe_ajax_after_front_editor_post_updated (action)
  5. bfe_ajax_after_front_editor_post_update_or_creation (action): fields save their meta here
  6. bfe_ajax_after_successfully_post_redirect or bfe_ajax_after_successfully_post_edited (filter): redirect URL

Actions

bfe_ajax_before_post_update_or_creation

Runs before anything is saved. Use it to validate. Stop the save with wp_send_json_error().

do_action('bfe_ajax_before_post_update_or_creation', $post_id, $form_id, $all_form_settings);
add_action('bfe_ajax_before_post_update_or_creation', function ($post_id, $form_id, $all_form_settings) {
    if (empty($_POST['text_fields']['phone'])) {
        wp_send_json_error(['field' => 'phone', 'message' => 'Please add your phone number']);
    }
}, 10, 3);

field is the field name to highlight, message is shown to the user.

bfe_ajax_after_front_editor_post_inserted

A new post was created.

do_action('bfe_ajax_after_front_editor_post_inserted', $post_id, $form_id);

bfe_ajax_after_front_editor_post_updated

An existing post was updated.

do_action('bfe_ajax_after_front_editor_post_updated', $post_id, $form_id);

bfe_ajax_after_front_editor_post_update_or_creation

After insert or update. Fields save their values here. $post_id is an int.

do_action('bfe_ajax_after_front_editor_post_update_or_creation', $post_id, $form_id, $post_data, $all_form_settings);
add_action('bfe_ajax_after_front_editor_post_update_or_creation', function ($post_id, $form_id) {
    if (isset($_POST['my_extra'])) {
        update_post_meta($post_id, 'my_extra', sanitize_text_field(wp_unslash($_POST['my_extra'])));
    }
}, 10, 2);

bfe_before_post_form_frontend_execution

Before a form is rendered on the front end.

do_action('bfe_before_post_form_frontend_execution', $attributes); // shortcode attributes, $attributes['id'] = form ID

bfe_editor_on_front_field_adding

Called once for every field of the form while it is rendered. Each field class prints its template here. Use it to render your own field type.

do_action('bfe_editor_on_front_field_adding', $post_id, $attributes, $field); // $field = field config from the builder

Action Hook field (Pro)

The Action Hook field calls an action with the name you enter:

do_action($field['action_hook_name'], $post_id, $attributes, $field, $all_form_settings);

bfe_ai_post_flagged (Pro)

AI moderation flagged a post.

do_action('bfe_ai_post_flagged', $post_id, $verdict);
// $verdict = ['flagged' => true, 'reason' => '…', 'categories' => […], 'checked_at' => 'Y-m-d H:i:s']
add_action('bfe_ai_post_flagged', function ($post_id, $verdict) {
    wp_mail(get_option('admin_email'), 'Post flagged', get_edit_post_link($post_id, 'raw') . "\n" . $verdict['reason']);
}, 10, 2);

Other actions

Action Parameters When
bfe_after_file_field_updated_in_back (Pro) $value (attachment IDs), $form_id, $_POST File field value saved
fe_before_wp_admin_form_create_save $_POST Admin saves a form in the builder
fe_before_gallery_block_images_html_render $image_id, $post_id EditorJS gallery/carousel image rendered
fe_before_simple_image_block_images_html_render $image_id, $post_id EditorJS image rendered
fe_post_forms_list_table_search_box $text, $input_id Forms list search box
BFE_activate / BFE_deactivate none Plugin activation / deactivation
fe_fs_loaded none Freemius SDK loaded

Filters

bfe_ajax_before_front_editor_post_update_or_creation

Change the data passed to wp_insert_post() / wp_update_post().

$post_data = apply_filters('bfe_ajax_before_front_editor_post_update_or_creation',
    $post_data, $_POST, $_FILES, $post_id, $form_id, $all_form_settings);
add_filter('bfe_ajax_before_front_editor_post_update_or_creation', function ($post_data, $request, $files, $post_id, $form_id) {
    if ((int) $form_id === 123) {
        $post_data['post_category'] = [7];
    }
    return $post_data;
}, 10, 5);

The plugin uses it itself (title, payments, moderation), so use priority 10 to 98 if you want the AI moderation (priority 99) to see your changes.

bfe_ajax_after_successfully_post_redirect / bfe_ajax_after_successfully_post_edited

The URL to redirect to after a new post / an update. Note: the first argument starts as the post ID; the plugin’s own callback at priority 10 replaces it with a URL or false. Hook later than 10.

apply_filters('bfe_ajax_after_successfully_post_redirect', $post_id, $form_id);
apply_filters('bfe_ajax_after_successfully_post_edited', $post_id, $form_id);
add_filter('bfe_ajax_after_successfully_post_redirect', function ($url, $form_id) {
    return (int) $form_id === 123 ? home_url('/thank-you/') : $url;
}, 20, 2);

Return false for no redirect.

bfe_form_theme

The design of a form on the front end (clean, default_2, default, no_style, modern-minimal, card-panel, corporate-professional, borderless-flat).

apply_filters('bfe_form_theme', $form_settings['form_theme'] ?? 'default_2', $form_id);

AI filters

Filter Parameters Use
bfe_ai_assistant_actions $actions Add, change or remove assistant actions
bfe_ai_assistant_available true Return false to hide the assistant for the current visitor
bfe_ai_client_ip $_SERVER['REMOTE_ADDR'] Real visitor IP behind a proxy or CDN (used for the guest daily limit)

Each action in $actions is keyed by slug:

add_filter('bfe_ai_assistant_actions', function ($actions) {
    $actions['summary'] = [
        'label' => __('Summarize', 'my-plugin'),
        'instruction' => 'Summarize the text in 3 sentences.',
        // 'needs_prompt' => true, 'prompt_placeholder' => '…'
    ];
    unset($actions['expand']);
    return $actions;
});

add_filter('bfe_ai_assistant_available', function ($available) {
    return $available && current_user_can('edit_posts');
});

Other filters

Filter Parameters Use
bfe_front_editor_localize_data $data, $attributes, $post_id Data passed to the front-end form script (window.editor_data)
fe_localize_post_html_content $data, $attributes, $post_id Existing content passed to editors when editing
bfe-editor-post-edit-button-html $html HTML of the Edit Post button on single posts
fe_admin_role 'manage_options' Capability for form list actions and design preview
admin_post_form_formBuilder_settings $data Builder config; fields register here (fields, typeUserAttrs, controls_group, …)
admin_post_form_formBuilder_add_controls_group $groups Add a field group to the builder panel
bfe_fe_post_form_backend_block_localize_data $data Data for the admin form builder script
bfe_front_editor_backend_block_localize_data $data Data for the Front Editor block in the block editor
bfe_settings_tabs $tabs Add tabs to Front User Submit → Settings
bfe_editor_data_to_html_filter $html, $type, $data HTML of one EditorJS block when saving
fus_editor_js_default_content [] Default EditorJS blocks for a new post
fus_display_field_value $value, $name, $post_id Value printed by [fus_display_field]
fe_post_forms_list_table_* various Columns, views, bulk actions and rows of the forms list

JavaScript hooks

The front-end form script exposes a small hook system as window.fe_hooks (WordPress-style add_action / do_action).

Event When
init_post_form The form script starts
on_post_form_save Submit or Save Draft is clicked
before_sending_ajax_request Right before the form data is sent
window.fe_hooks.add_action('on_post_form_save', () => {
    console.log('Form is being saved');
});

Last updated 2026-11-18