Using Gravity Forms ‘gform_export_form’ PHP action

The gform_export_form Gravity Forms PHP filter allows you to modify the form meta before export.

Usage

Apply the filter to all forms:

add_filter('gform_export_form', 'modify_form_for_export', 10, 1);

To target a specific form, append the form id to the hook name (format: gform_export_form_FORMID):

add_filter('gform_export_form_1', 'modify_form_for_export', 10, 1);

Parameters

  • $form (Form Object): The current form.

More information

See Gravity Forms Docs: gform_export_form

Examples

Mark form as exported

This example sets the ‘exported’ key in the form meta to true.

add_filter('gform_export_form', 'modify_form_for_export');

function modify_form_for_export($form) {
    $form['exported'] = true;
    return $form;
}

Add prefix to form title

This example adds the “Export of” prefix to the form title during export.

add_filter('gform_export_form', 'modify_form_for_export');

function modify_form_for_export($form) {
    $form['title'] = 'Export of ' . $form['title'];
    return $form;
}

Remove specific field from form export

This example removes a field with a specific ID from the form export.

add_filter('gform_export_form', 'remove_field_from_export');

function remove_field_from_export($form) {
    foreach ($form['fields'] as $key => $field) {
        if ($field->id == 3) {
            unset($form['fields'][$key]);
        }
    }
    return $form;
}

Export only enabled forms

This example exports only forms that have the ‘isEnabled’ key set to true.

add_filter('gform_export_form', 'export_only_enabled_forms');

function export_only_enabled_forms($form) {
    if (isset($form['isEnabled']) && $form['isEnabled']) {
        return $form;
    }
    return null;
}

Set form export date

This example sets the ‘export_date’ key in the form meta to the current date during export.

add_filter('gform_export_form', 'set_form_export_date');

function set_form_export_date($form) {
    $form['export_date'] = date('Y-m-d');
    return $form;
}