Created
October 17, 2019 17:13
-
-
Save hreidco/4b6f5f2a7f9f0337e6d2650b428cebe1 to your computer and use it in GitHub Desktop.
Add WP username to EE registration CSV
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
//* Add WP username to EE registration CSV ---------------------------------------------------------------*/ | |
function ee_add_wp_username_to_csv($reg_csv_array, $reg_row) { | |
//d($reg_row); | |
$reg_csv_array['WP Username'] = ''; | |
$primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; | |
if( $primary_reg ) { | |
$user_id = EE_WPUsers::get_attendee_user($reg_row['Registration.ATT_ID']); | |
//d($user_id); | |
if( $user_id != false ) { | |
$user = get_userdata( $user_id ); | |
//d($user); | |
if( $user instanceof WP_User ) { | |
//d($user_id); | |
$reg_csv_array['WP Username'] = $user->user_login; | |
} | |
} | |
} | |
return $reg_csv_array; | |
} | |
add_filter( 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', 'ee_add_wp_username_to_csv', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment