Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Created September 14, 2020 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzocaum/052f06330522c74d3e271df3066fb782 to your computer and use it in GitHub Desktop.
Save lorenzocaum/052f06330522c74d3e271df3066fb782 to your computer and use it in GitHub Desktop.
//-----------------------------------------------------------------------------//
// Used by: Registraction CSV Export (button Filtered CSV Export)                                           //
// Purpose: Include additional fields from the Ultimate Member Plugin data from the wp_usermeta table       //
// Usage  : Include meta keys in array $meta_keys_include to obtain meta data as additional csv column.     //
//----------------------------------------------------------------------------------------------------------//
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'ssci_add_um_fields_to_export', 10, 2);

function ssci_add_um_fields_to_export( $reg_csv_array, $reg_row ) {

   // Add Altimate Member meta_key values that you want to include in the CSV Array from table wp_usermeta 
   $meta_keys_include = array(
			'member_program_yn',
			'dvsv_organization',
			'phone_number',
			'kcsdv_address',
			'city_kcsdv',
			'state_kcsdv',
			'title',
			'your_profession',
			'job_type',
			'professional_type'
	        );

    // Initialize All meta key Values to Nothing (creates column headings in CSV)
    foreach ($meta_keys_include as $column) {       
    	$reg_csv_array[$column] = '';     
    }
    
    //Do we have a wp_user for this attendee record?
	$user_id = EE_WPUsers::get_attendee_user($reg_row['Registration.ATT_ID']);
        
	if (!empty($user_id)) {
    	//You have a user id saved to $user_id.        
        // Get meta data for desired meta key
        foreach ($meta_keys_include as $key) {       
        	$reg_csv_array[$key] = get_user_meta($user_id, $key, true);
        }
	}
    
   // always return csv array		
   return $reg_csv_array;

} //End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment