Hooks for Developers

October 26, 2026
Developers
12 views
3 min read
Updated October 27, 2026

FormGlut has PHP hooks and front-end events so you can extend it. The full reference is in the EXTENDING.md file inside the plugin folder.

Run code after every submission

formglut_entry_submitted runs after every accepted submission (not spam):

add_action( 'formglut_entry_submitted', function ( $form, $fields_data, $entry_id ) {
    if ( 3 !== (int) $form->id ) {
        return;
    }
    // $fields_data holds the answers, keyed by field ID.
    error_log( 'New entry #' . $entry_id );
}, 10, 3 );

$form is the form object ($form->id, $form->title). $entry_id is 0 when the form does not save entries.

Submission hooks (in the order they run)

HookTypeUse
formglut_pre_submissionfilterReturn a WP_Error to refuse a submission.
formglut_validate_field_valuefilterExtra checks on any field.
formglut_sanitize_field_valuefilterChange a cleaned value.
formglut_submission_errorsfilterChecks that compare several fields.
formglut_spam_checkfilterReturn a reason to mark the entry as spam.
formglut_submission_datafilterChange the answers before payment and saving.
formglut_payment_totalfilterChange the amount to charge.
formglut_entry_datafilterChange the row that is saved.
formglut_entry_createdactionAfter the entry is saved.
formglut_pre_send_notificationsfilterReturn true to send the notifications yourself.
formglut_notification_emailfilterChange an email (to, subject, body, headers, attachments).
formglut_entry_submittedactionAfter an accepted submission.
formglut_submission_responsefilterChange the reply sent to the browser.
formglut_replace_tagsfilterAdd your own smart tags.

Form output hooks

HookTypeUse
formglut_form_availabilityfilterClose a form with your own reason and message.
formglut_form_attributesfilterAdd attributes to the <form> tag.
formglut_form_fields_before / formglut_form_fields_afteractionPrint output inside the form.
formglut_form_htmlfilterChange the whole form HTML.
formglut_field_configfilterChange a field before it is drawn and checked, for example dynamic choices.
formglut_display_valuefilterChange how a value is shown in emails, tags, exports and the entry screen.

Forms and entries

HookUse
formglut_form_created, formglut_before_form_update, formglut_before_form_deleteReact to form changes.
formglut_before_entry_delete, formglut_before_entry_status_changeReact to entry changes.
formglut_disposable_email_domainsAdd or remove throwaway email domains.
formglut_currenciesAdd currencies.
formglut_capabilityChange the capability needed for FormGlut screens.

Form templates

Templates are read only when someone opens the template picker. Each template lists only what differs from the field type’s defaults; choices need only a label.

HookUse
formglut_templatesFilter. Add templates to the picker. To load a folder of template files: FormGlut_Templates::load_dir( $dir, 'my-plugin' ).
formglut_template_categoriesFilter. Add categories (slug => label).

Give a field 'ref' => 'name' and write {ref:name} in a settings text to insert that field’s value. icon is a Font Awesome icon name.

add_filter( 'formglut_templates', function ( $templates ) {
    $templates[] = array(
        'slug'        => 'my_booking',
        'title'       => 'My booking form',
        'description' => 'Name, email and a date.',
        'icon'        => 'faCalendarDays',
        'category'    => 'events',
        'fields'      => array(
            array( 'type' => 'name' ),
            array( 'type' => 'email', 'label' => 'Email', 'required' => true ),
            array( 'type' => 'date', 'label' => 'Date', 'ref' => 'date' ),
        ),
        'settings'    => array(
            'confirmation' => array( 'message' => 'See you on {ref:date}!' ),
        ),
    );
    return $templates;
} );

Front-end events

Events fire on the form element and bubble up:

EventDetail
formglut:init{ formId, form }
formglut:before-submit{ formId, form, formData }. Cancelable. Add values to formData.
formglut:submitted{ formId, entryId, response }

Example: track a conversion.

document.addEventListener( 'formglut:submitted', function ( e ) {
    if ( window.gtag ) {
        gtag( 'event', 'generate_lead', { form_id: e.detail.formId } );
    }
} );

For a single form, you can also use Settings › Layout & CSS › JavaScript after submit.