Hooks Reference

  • JNext lesson
  • KPrevious lesson
  • FSearch lessons
  • EscClear search

Core Forms provides an extensive set of actions and filters for developers to customize every aspect of form rendering, processing, and administration.

Form Rendering Filters

cf_form_html

Filters the complete HTML output of a form, including the <form> tag, hidden fields, and wrapper elements.

add_filter( 'cf_form_html', function( $html, $form ) {
    return $html;
}, 10, 2 );

Parameters:

  • $html (string) – The complete form HTML.
  • $form (Form) – The Form object.

cf_form_markup

Filters the inner form markup (the content you write in the Fields tab), before it is wrapped in the form element.

add_filter( 'cf_form_markup', function( $markup, $form ) {
    return $markup;
}, 10, 2 );

Parameters:

  • $markup (string) – The form field markup HTML.
  • $form (Form) – The Form object.

cf_form_element_class_attr

Filters the CSS class string added to the <form> element.

add_filter( 'cf_form_element_class_attr', function( $classes, $form ) {
    return $classes . ' my-custom-class';
}, 10, 2 );

cf_form_element_action_attr

Filters the action attribute of the <form> element. By default, this is null (no action attribute), and the form submits via AJAX.

add_filter( 'cf_form_element_action_attr', function( $action, $form ) {
    return $action;
}, 10, 2 );

cf_form_element_data_attributes

Filters the array of data attributes added to the <form> element.

add_filter( 'cf_form_element_data_attributes', function( $attributes, $form ) {
    $attributes['custom'] = 'value';
    return $attributes;
}, 10, 2 );

cf_form_message_{code}

Filters a specific form message. The {code} is the message key (e.g., success, error, required_field_missing).

add_filter( 'cf_form_message_success', function( $message, $form ) {
    return 'Thanks! Got it.';
}, 10, 2 );

cf_form_default_messages

Filters the array of default messages for all forms.

add_filter( 'cf_form_default_messages', function( $messages ) {
    $messages['success'] = 'Received!';
    return $messages;
} );

cf_form_default_settings

Filters the array of default settings for all forms. Extensions use this to register their own settings.

add_filter( 'cf_form_default_settings', function( $settings ) {
    $settings['my_setting'] = 'default';
    return $settings;
} );

Form Processing Hooks

cf_process_form

Fires at the start of form processing, before validation results are checked.

add_action( 'cf_process_form', function( $form, $submission, $data, $error_code ) {
    // Runs for every submission, even invalid ones
}, 10, 4 );

cf_validate_form

Filters the validation error code. Return a non-empty string to reject the submission. The string is used as the message key.

add_filter( 'cf_validate_form', function( $error_code, $form, $data ) {
    if ( $form->slug === 'application' && empty( $data['resume'] ) ) {
        return 'required_field_missing';
    }
    return $error_code;
}, 10, 3 );

cf_form_success

Fires after a successful submission, before form actions are processed.

add_action( 'cf_form_success', function( $submission, $form ) {
    // Submission validated, about to run actions
}, 10, 2 );

cf_submission_inserted

Fires after a submission is saved to the database.

add_action( 'cf_submission_inserted', function( $submission, $form ) {
    // $submission->id is now available
}, 10, 2 );

cf_form_response

Fires after form processing is complete, including when there are errors.

add_action( 'cf_form_response', function( $form, $submission, $error_code ) {
    // Runs after every submission attempt
}, 10, 3 );

cf_form_redirect_url

Filters the redirect URL after a successful submission.

add_filter( 'cf_form_redirect_url', function( $url, $form, $data ) {
    return $url;
}, 10, 3 );

cf_ignored_field_names

Filters the array of field names that should be excluded from submission data.

add_filter( 'cf_ignored_field_names', function( $names ) {
    $names[] = 'tracking_pixel';
    return $names;
} );

cf_shortcode_form_identifier

Filters the form identifier (slug or ID) before the form is loaded.

add_filter( 'cf_shortcode_form_identifier', function( $identifier, $attributes ) {
    return $identifier;
}, 10, 2 );

Action Processing Hooks

cf_available_form_actions

Filters the array of available form action types. Each action class uses this to register itself.

add_filter( 'cf_available_form_actions', function( $actions ) {
    $actions['my_action'] = 'My Custom Action';
    return $actions;
} );

cf_process_form_action_{type}

Fires when a specific action type needs to be processed.

add_action( 'cf_process_form_action_email', function( $settings, $submission, $form ) {
    // Email action is being processed
}, 10, 3 );

cf_output_form_action_{type}_settings

Fires when a specific action type’s settings should be rendered in the admin.

add_action( 'cf_output_form_action_webhook_settings', function( $settings, $index ) {
    // Render webhook settings HTML
}, 10, 2 );

Email Action Filters

cf_action_email_to

Filters the email recipient.

cf_action_email_subject

Filters the email subject.

cf_action_email_message

Filters the email message body.

cf_action_email_from

Filters the email sender address.

All email filters receive ($value, $submission) as parameters.

Auto-Responder Filters

cf_action_autoresponder_to

Filters the auto-responder recipient.

cf_action_autoresponder_subject

Filters the auto-responder subject.

cf_action_autoresponder_message

Filters the auto-responder message body.

cf_action_autoresponder_headers

Filters the auto-responder email headers array.

Webhook Hooks

cf_webhook_request_args

Filters the webhook request arguments before sending.

add_filter( 'cf_webhook_request_args', function( $args, $settings, $submission, $form ) {
    return $args;
}, 10, 4 );

cf_webhook_response

Fires after a webhook request completes.

add_action( 'cf_webhook_response', function( $response, $settings, $submission, $form ) {
    // Check response status
}, 10, 4 );

Template Tags

cf_template_tags

Filters the available template tag replacers for {{tag}} syntax.

add_filter( 'cf_template_tags', function( $tags ) {
    $tags['custom'] = function( $param ) {
        return "custom_$param";
    };
    return $tags;
} );

Admin Hooks

cf_admin_action_{action}

Fires when a custom admin action is triggered.

cf_admin_output_form_tab_{tab}

Fires to render the content of a form editing tab.

cf_admin_output_form_messages

Fires to output additional message fields in the Messages tab.

cf_admin_output_form_settings

Fires to output additional settings in the form Settings tab.

cf_admin_output_settings

Fires to output additional fields on the global Settings page.

cf_admin_tabs

Filters the array of tabs shown when editing a form.

add_filter( 'cf_admin_tabs', function( $tabs, $form ) {
    $tabs['analytics'] = 'Analytics';
    return $tabs;
}, 10, 2 );

cf_output_table_data_columns

Fires when rendering submission table columns.

Field Type Filter

cf_available_field_types

Filters the list of available field types in the form builder sidebar.

add_filter( 'cf_available_field_types', function( $types ) {
    $types['color'] = array(
        'text' => 'Color Picker',
        'type' => 'input',
    );
    return $types;
} );

Settings Filter

cf_settings

Filters the global plugin settings after they are loaded from the database.

add_filter( 'cf_settings', function( $settings ) {
    return $settings;
} );

Accessibility

cf_form_markup (priority 100)

The cf_enhance_accessibility function is hooked here to automatically add ARIA attributes, label associations, and other accessibility improvements to form markup.

Fullscreen Forms

cf_fullscreen_head

Fires in the <head> section of the fullscreen form page.

cf_fullscreen_footer

Fires before </body> in the fullscreen form page.

File Upload

cf_file_upload_use_direct_links

Filters whether file links in submissions should use direct URLs instead of WordPress attachment edit links.

add_filter( 'cf_file_upload_use_direct_links', '__return_true' );