Advertisement
Guest User

ee_csv_export_order

a guest
Jan 29th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.47 KB | None | 0 0
  1. // Set up custom CSV Export to match the ordering of the client's current csv and filter out extraneous columns
  2. function tw_ee_espresso_reg_report_filter_columns_ordered( $csv_row, $registration_db_row ) {
  3.     //Set the allowed fields here and also set them in the order you want them to be displayed within the CSV
  4.     $allowed_fields_in_order = array(
  5.         __( 'Registration ID', 'event_espresso' ) . '[REG_ID]',
  6.         __( 'Event', 'event_espresso' ),
  7.         __( 'affiliated-membership', 'event_espresso' ),
  8.         __( 'Ticket Name', 'event_espresso' ),
  9.         __( 'First Name', 'event_espresso' ) . '[ATT_fname]',
  10.         __( 'middle_initial', 'event_espresso' ),
  11.         __( 'Last Name', 'event_espresso' ) . '[ATT_lname]',
  12.         __( 'Email Address', 'event_espresso' ) . '[ATT_email]',
  13.         __( 'county_official', 'event_espresso' ),
  14.         __( 'county', 'event_espresso' ),
  15.         __( 'title', 'event_espresso' ),
  16.         __( 'employer', 'event_espresso' ),
  17.         __( 'departmentdivision', 'event_espresso' ),
  18.         __( 'gluten-free', 'event_espresso' ),
  19.         __( 'vegetarian', 'event_espresso' ),
  20.         __( 'vegan', 'event_espresso' ),
  21.         __( 'authorizing_name', 'event_espresso' ),
  22.         __( 'authorizing_title', 'event_espresso' ),
  23.         __( 'authorizing_email', 'event_espresso' ),
  24.         __( 'Address Part 1', 'event_espresso' ) . '[ATT_address]',
  25.         __( 'Address Part 2', 'event_espresso' ) . '[ATT_address2]',
  26.         __( 'City', 'event_espresso' ) . '[ATT_city]',
  27.         __( 'State', 'event_espresso' ) . '[STA_ID]',
  28.         __( 'Country', 'event_espresso' ) . '[CNT_ISO]',
  29.         __( 'ZIP/Postal Code', 'event_espresso' ) . '[ATT_zip]',
  30.         __( 'Phone', 'event_espresso' ) . '[ATT_phone]',
  31.         __( 'cell_number', 'event_espresso' ),
  32.         __( 'fax', 'event_espresso' ),
  33.         __( 'comments', 'event_espresso' ),
  34.         __( 'Registration's share of the transaction total', 'event_espresso' ) . '[REG_final_price]',
  35.         __( 'Amount Paid', 'event_espresso' ),
  36.         __( 'Registration Status', 'event_espresso' ),
  37.         __( 'Time registration occurred', 'event_espresso' ) . '[REG_date]',
  38.     );
  39.     //Sets $filtered_csv_row to only contain the 'allowed' fields.
  40.     $filtered_csv_row = array_intersect_key(
  41.             $csv_row,
  42.             array_flip( $allowed_fields_in_order )
  43.         );
  44.    
  45.     //Now lets set $filtered_csv_row to use the same custom order we set $allowed_fields_in_order to
  46.     $filtered_csv_row = array_merge(array_flip($allowed_fields_in_order), $filtered_csv_row );
  47.     return $filtered_csv_row;
  48. }
  49. add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'tw_ee_espresso_reg_report_filter_columns_ordered', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement