bookmark_bordergform_entry_meta

Description

Use this hook to add custom properties to the Entry object. Allows entry meta data to be added 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

    Entry meta array.

  • $form_id integer

    The ID of the form from which the entry value was submitted.

Examples

This example adds two entry meta columns (score and test). The “score” column is added automatically to the entry list, while the “test” column has to be added manually by editing the entry columns in the admin.

add_filter( 'gform_entry_meta', 'custom_entry_meta', 10, 2);
function custom_entry_meta($entry_meta, $form_id){
    //data will be stored with the meta key named score
    //label - entry list will use Score as the column header
    //is_numeric - used when sorting the entry list, indicates whether the data should be treated as numeric when sorting
    //is_default_column - when set to true automatically adds the column to the entry list, without having to edit and add the column for display
    //update_entry_meta_callback - indicates what function to call to update the entry meta upon form submission or editing an entry
    $entry_meta['score'] = array(
        'label' => 'Score',
        'is_numeric' => true,
        'update_entry_meta_callback' => 'update_entry_meta',
        'is_default_column' => true
    );
    //data will be stored with the meta key named test
    $entry_meta['test'] = array(
        'label' => 'Test',
        'is_numeric' => false,
        'update_entry_meta_callback' => 'update_entry_meta_test',
        'is_default_column' => false
    );
    return $entry_meta;
}

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

function update_entry_meta_test( $key, $lead, $form ){
    //update test
    $value = "thisisatest";
    return $value;
}

Placement

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

Source Code

This action hook is located in GFFormsModel::get_entry_meta() in forms_model.php