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


add_filter( 'gform_form_tag', 'form_tag', 10, 2 );


  • $form_tag string

    The string containing the <form> tag

  • $form

    The current form.


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

add_filter( 'gform_form_tag', 'form_tag', 10, 2 );
function form_tag( $form_tag, $form ) {
    if ( $form['id'] != 3 ) {
        //not the form whose tag you want to change, return the unchanged tag
        return $form_tag;
    $form_tag = preg_replace( "|action='(.*?)'|", "action='custom_handler.php'", $form_tag );
    return $form_tag;


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

Source Code

This filter is located in GFFormDisplay::get_form() in form_display.php

Third-party Resources

Plugin: Gravity Forms Tag Editor

A simple plugin that makes modifying Gravity Forms tags a breeze. Change any attribute of the form tag with just a few lines of code. Visit the plugin page.

Last modified: October 4, 2017