Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active July 4, 2016 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amdrew/e0df923a629ff2c56ec5 to your computer and use it in GitHub Desktop.
Save amdrew/e0df923a629ff2c56ec5 to your computer and use it in GitHub Desktop.
AffiliateWP - Add the customer's first name, last name and email who the affiliate referred as columns in the exported referrals .csv file
<?php
/**
* Add new columns to the exported referrals CSV file for the customer's first name, last name and email address
*/
function affwp_custom_export_referrals_csv_cols( $cols ) {
$cols['customer_first_name'] = 'Customer First Name';
$cols['customer_last_name'] = 'Customer Last Name';
$cols['customer_email'] = 'Customer Email';
return $cols;
}
add_filter( 'affwp_export_csv_cols_referrals', 'affwp_custom_export_referrals_csv_cols' );
/**
* Add the customer's first name, last name and email address to our new csv columns
*/
function affwp_custom_export_get_data_referrals( $data ) {
foreach ( $data as $key => $d ) {
// get EDD payment user info
$payment_user_info = edd_get_payment_meta_user_info( $data[$key]['reference'] );
$customer_first_name = isset( $payment_user_info['first_name'] ) ? $payment_user_info['first_name'] : '';
$customer_last_name = isset( $payment_user_info['last_name'] ) ? $payment_user_info['last_name'] : '';
$customer_email = isset( $payment_user_info['email'] ) ? $payment_user_info['email'] : '';
$data[$key]['customer_first_name'] = $customer_first_name;
$data[$key]['customer_last_name'] = $customer_last_name;
$data[$key]['customer_email'] = $customer_email;
}
return $data;
}
add_filter( 'affwp_export_get_data_referrals', 'affwp_custom_export_get_data_referrals' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment