Using Gravity Forms ‘gform_entry_meta’ PHP filter

The gform_entry_meta filter in Gravity Forms allows you to add custom properties to the Entry object. This helps you add entry meta data as sortable columns to the entry list and export entries file.

Usage

add_filter('gform_entry_meta', 'custom_entry_meta', 10, 2);

Parameters

  • $entry_meta (array): The entry meta array.
  • $form_id (integer): The ID of the form from which the entry value was submitted.

More information

See Gravity Forms Docs: gform_entry_meta

Examples

Basic meta column

Add a basic meta column to the entry list with a numeric value.

add_filter('gform_entry_meta', 'custom_entry_meta', 10, 2);

function custom_entry_meta($entry_meta, $form_id) {
    $entry_meta['score'] = array(
        'label' => 'Score',
        'is_numeric' => true,
        'update_entry_meta_callback' => 'update_entry_meta',
        'is_default_column' => true
    );

    return $entry_meta;
}

function update_entry_meta($key, $lead, $form) {
    $value = "5";
    return $value;
}

Meta column with filters

Add a meta column with filters to the entry list.

add_filter('gform_entry_meta', function ($entry_meta, $form_id) {
    $entry_meta['test'] = array(
        'label' => 'Test',
        'is_numeric' => false,
        'update_entry_meta_callback' => 'update_entry_meta_test',
        'is_default_column' => false,
        'filter' => array(
            'key' => 'test',
            'text' => 'Test',
            'operators' => array(
                'is',
                'isnot',
            )
        ),
    );

    return $entry_meta;
}, 10, 2);

function update_entry_meta_test($key, $entry, $form) {
    $value = "thisisatest";
    return $value;
}

Quiz Add-On Meta

Add entry meta for Gravity Forms Quiz Add-On fields.

add_filter('gform_entry_meta', array('GFQuiz', 'entry_meta'), 10, 2);

// Place the rest of the example code in the corresponding GFQuiz class file

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

This filter was added in Gravity Forms version 1.7.

The source code for this action hook is located in GFFormsModel::get_entry_meta() in forms_model.php.