Last active
September 30, 2021 13:34
-
-
Save adczk/63e7a8ac987eca4e9a6dc23f1c7d9935 to your computer and use it in GitHub Desktop.
Forminator 1.15.3 - include entry_id and user IP in CSV export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Forminator] - include entry ID and user IP in CSV export | |
* Description: [Forminator] - automatically includes entry ID and user IP in CSV export | |
* Author: Adam @ WPMUDEV | |
* Author URI: https://wpmudev.com | |
* License: GPLv2 or later | |
* | |
* Tested with Forminator 1.15.3 (backwards/future compatibility unknown) | |
*/ | |
function wpmu_forminator_include_internal_fields_in_csv ($mappers, $model_id, $model ) { | |
// to change order of Entry ID and User IP columns, switch order of arrays below | |
$sub_mappers[] = array( | |
'property' => 'entry_id', | |
'label' => 'Entry ID', | |
'type' => 'entry_id' | |
); | |
$sub_mappers[] = array( | |
'meta_key' => '_forminator_user_ip', | |
'label' => 'User IP', | |
'type' => 'text' | |
); | |
// to put entry_id and IP as last 2 columns, switch order of $mappers and $sub_mappers below | |
$result_mappers = array_merge( $sub_mappers, $mappers ); | |
return $result_mappers; | |
} | |
add_filter( 'forminator_custom_form_export_mappers', 'wpmu_forminator_include_internal_fields_in_csv', 10, 3); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment