GravityExport field: MetaField
Gravity Forms adds some data on top of the fields in a form. Things like an IP address, a timestamp, etc. All this meta data is being provided by a single meta ย field. Therefor we created this MetaField ย class. This way you can target every individual meta field in the export for changing, and it has itโs own filters.
Because these meta fields closely resemble the other fields, the plugin has a tiny meta fields Transformer ย baked in. This allows you to (also) register your own (custom) MetaField ย instances. You can add your fields via the filter. The plugin actually already has a custom MetaField ย called DateCreatedField.
Filters #
gfexcel_meta_value_{field_id}_{form_id}Just as itโs big brother for the field value, this filter can change the value of this meta field. The extra options are reversed on purpose, because itโs more likely youโll want to change every meta field (type), that for a specific form.
/**
* Filters the exported IP meta value in GravityExport exports.
*
* This hook allows you to modify the IP address value before itโs written to the export file.
* In this example, a prefix is added before the IP address.
*
* @since 1.0.0
*
* @param string $value The original IP address value.
* @param array $entry The full Gravity Forms entry array.
* @param GF_Field $field The field object associated with the meta value (if applicable).
*
* @return string The modified IP address value.
*/
add_filter(
'gfexcel_meta_value_ip',
function ( $value, $entry, $field ) {
return 'IP:' . $value;
},
10,
3
);gfexcel_transformer_subfieldsThis filter allows you to add your own (custom)
MetaFieldย instance for a specific type. Let say you created aIpAddressFieldย and you want to register it for theipย field.
Example
/**
* Registers a custom transformer class for specific subfields in GravityExport.
*
* This filter allows you to define custom logic for transforming the value
* of specific subfields during export by mapping a subfield key to a fully qualified class name.
*
* @since 1.0.0
*
* @param array $fields An associative array of subfield keys mapped to their transformer classes.
* Example: [ 'ip' => 'Your\Full\Namespace\IpAddressField' ].
*
* @return array The modified array of subfield transformer mappings.
*/
add_filter(
'gfexcel_transformer_subfields',
function ( $fields ) {
$fields['ip'] = 'Your\Full\Namespace\IpAddressField';
return $fields;
}
);DateCreatedField #
This actually is a custom MetaField ย instance, that allows you to split the timestamp into two fields; Date ย and Time .
Filters #
gfexcel_meta_date_created_separated_{form_id}allows you to separate the timestamp into two fields.
Example
/**
* Splits the "date_created" meta field into separate date and time columns
* in GravityExport exports.
*
* By returning true, the export will include two columns:
* one for the date and another for the time of entry creation.
*
* @since 1.0.0
*
* @return bool True to separate the date_created field into date and time fields.
*/
add_filter( 'gfexcel_meta_date_created_separated', '__return_true' );