Description

The filter can be used to manipulate the data being requested and exported from the form entries.

Parameters

$export_data
(array) An array of information to be exported from the entry.
$request_data
(array) An array of information requested from the entry.

Source

wpforms/src/Pro/Admin/Entries/Export/Ajax.php

More Information

The wpforms_pro_admin_entries_export_ajax_get_entry_data filter can be used to manipulate the data being requested and exported from the form entries.

Examples

This example snippet below will export the entries from the form and use the full country name instead of just showing the country code.

/**
 * Display full country name instead of showing country code in entry export.
 *
 * @link   https://wpforms.com/developers/wpforms_pro_admin_entries_export_ajax_get_entry_data/
 *
 * @param array $export_data  Field properties.
 * @param array $request_data Field settings.
 *
 * @return array
 */
function wpf_dev_pro_country_code_to_country_name_replace( $export_data, $request_data ) {
	
	// Your address field ID.
	$field_id = 10;
	if ( empty( $export_data[ $field_id ] ) ) {
		return $export_data;
	}
	
	$counties = wpforms_countries();
	
	foreach ( $counties as $code => $country ) {
		$export_data[ $field_id ] = preg_replace( "/{$code}$/", $country, $export_data[ $field_id ] );
	}
	
	return $export_data;
	
}
add_filter( 'wpforms_pro_admin_entries_export_ajax_get_entry_data', 'wpf_dev_pro_country_code_to_country_name_replace', 10, 2 );

Remember to change the $field_id number to match the field ID from your form. For assistance with this, please review this tutorial.

Snippet References: How To Remove Line Breaks From CSV Exports

FAQ

Q: Can I use this snippet for a specific form instead of using the field ID?

A: If you’d like to use the form ID instead of the field ID, use this code snippet instead.

/**
 * Display full country name instead of showing country code in entry export.
 *
 * @link   https://wpforms.com/developers/wpforms_pro_admin_entries_export_ajax_get_entry_data/
 *
 * @param array $export_data  Field properties.
 * @param array $request_data Field settings.
 *
 * @return array
 */

function wpf_dev_pro_country_code_to_country_name_replace( $export_data, $request_data ) {

   $counties = wpforms_countries();

   // Start: Comment it out if you want to use this snippet for all forms.
   // Your Form ID.
   $form_id = 421930;

   if ( (int) $request_data[ 'form_data' ][ 'id' ] !== $form_id ) {
      return $export_data;
   }

   // End: Comment it out if you want to use this snippet for all forms.
   foreach ( $export_data as $i => $v ) {
      if ( $request_data[ 'form_data' ][ 'fields' ][ $i ][ 'type' ] !== 'address' ) {
         continue;
      }

      foreach ( $counties as $code => $country ) {
         $export_data[ $i ] = preg_replace( "/{$code}$/", $country, $export_data[ $i ] );
       }
   }

   return $export_data;

}
add_filter( 'wpforms_pro_admin_entries_export_ajax_get_entry_data', 'wpf_dev_pro_country_code_to_country_name_replace', 10, 2 );