Gform form tag

Description

This filter is executed when the form is displayed and can be used to completely change the form tag (i.e. <form method="post">).

Usage

<?php
add_filter("gform_form_tag", "form_tag", 10, 2);
?>

Parameters

$form_tag

(string) The string containing the <form> tag

$form

(Form Object) The current form.

Examples

This example changes the action of the form tag, submitting the form to a custom form handler.


<?php
add_filter("gform_form_tag", "form_tag", 10, 2);
function form_tag($form_tag, $form){
    $form_tag = preg_replace("|action='(.*?)'|", "action='custom_handler.php'", $form_tag);
    return $form_tag;
}
?>

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in form_display.php

Search the Documentation