gform_form_update_meta

Description

Allows modifying the form meta before it is saved to the database.

Usage

The following would apply to all forms:

add_filter( 'gform_form_update_meta', 'my_import_form', 10, 3 );

To target a specific form, append the form ID to the hook name. (format: gform_form_update_meta_FORMID):

add_filter( 'gform_form_update_meta_1', 'my_import_form', 10, 3 );

Parameters

  • $form_meta string
    The meta data for the current form.

  • $form_id int
    The current form ID.

  • $meta_name string
    Meta name.

Example

add_filter( 'gform_form_update_meta', 'my_import_form', 10, 3 );

function my_import_form( $meta, $form_id, $meta_name ) {
    $is_import_page           = GFForms::get_page() == 'import_form';
    $is_updating_display_meta = $meta_name == 'display_meta';

    if ( ! $is_import_page || ! $is_updating_display_meta ) {
        return $meta;
    }

    $form = $meta;
    $form['isImported'] = true;

    return $form;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms version 1.8.8.

Source Code

This filter is located in GFFormsModel::update_form_meta() in forms_model.php.