Last active
July 4, 2016 19:48
-
-
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
This file contains 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 | |
/** | |
* 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