Last active
October 25, 2018 21:22
-
-
Save codelion7/e6ed58e5d97514583b807b3f95e46df9 to your computer and use it in GitHub Desktop.
Add Parent Affiliate Column to Referrals 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 | |
/** | |
* Add new column to the exported referrals CSV file for the affiliate's Parent | |
*/ | |
function affwp_mlm_export_referrals_csv_cols( $cols ) { | |
$cols['parent_name'] = 'Parent Affiliate'; | |
return $cols; | |
} | |
add_filter( 'affwp_export_csv_cols_referrals', 'affwp_mlm_export_referrals_csv_cols' ); | |
/** | |
* Add the the affiliate's Parent to our new csv column | |
*/ | |
function affwp_mlm_export_get_data_referrals( $data ) { | |
foreach ( $data as $key => $d ) { | |
$affiliate_id = $data[$key]['affiliate_id']; | |
$parent_id = affwp_mlm_get_parent_affiliate( $affiliate_id ); | |
$parent_name = ( ! empty( $parent_id ) ) ? affiliate_wp()->affiliates->get_affiliate_name( $parent_id ) : 'None'; | |
$data[$key]['parent_name'] = $parent_name; | |
} | |
return $data; | |
} | |
add_filter( 'affwp_export_get_data_referrals', 'affwp_mlm_export_get_data_referrals' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment