Support

Home Forums Event Espresso Premium add field “affiliate name” and its content to csv export of EE registrations

add field “affiliate name” and its content to csv export of EE registrations

Posted: October 28, 2024 at 1:02 pm

Viewing 5 reply threads


Markahn

October 28, 2024 at 1:02 pm

Some years ago I installed a plugin I completed with the help of EE-Support (e.g. Tony) where I added some extra columns like that:

function ee_exclude_custom_fields_from_export($reg_csv_array, $reg_row) {

//within this function I added to more columns to the csv export file:
if ( array_key_exists( “Ticketname”, $reg_csv_array )) {
//If the field is set remove it from the array.
$str = “Automatic”;
$a = $reg_csv_array[ ‘Ticketname’ ];
// wenn Automatic in Ticketname then…
if (strpos($a, $str) !== false) {
$reg_csv_array[ ‘fahrzeugtyp’ ] = “A”; }
else {
$reg_csv_array[ ‘fahrzeugtyp’ ] = “S”; }
unset ($reg_csv_array[ ‘Ticketname’ ]);
}

$event_id = $reg_row[ ‘Registration.EVT_ID’ ];
// getting the post meta for instruktoren
$instruktoren = get_post_meta( $event_id, ‘Instruktoren’, true );
if ( $instruktoren != ” ) {
$reg_csv_array[ ‘Instruktoren’ ] = $instruktoren;
}
else {
$reg_csv_array[ ‘Instruktoren’ ] = “no Instruktor given”;
}
return $reg_csv_array;
}

add_filter( ‘FHEE__EE_Export__report_registrations__reg_csv_array’, ‘ee_exclude_custom_fields_from_export’, 100, 2 );

Now I need to add the name of the affiliate (from WP-Affiliate-Plugin) to the output of each row of the CSV export file (in case there is one connected to a ticket-booking) . Can You help me with that?


Tony

  • Support Staff

October 28, 2024 at 5:23 pm

Hi there,

May I ask which part of the above are you struggling with?

Grabbing an instance of awp can be done with:

$awp = function_exists('affiliate_wp') ? affiliate_wp() : null;

Then is you have an instance of AWP, use it to pull in the referral based on the TXN_ID:

if ( $awp instanceof Affiliate_WP ) {
    $referral = $awp->referrals->get_by('reference', $TXN_ID, 'event_espresso'))
}

(The TXN_ID you can get form the reg_row.

Then pull the details you need from the $ referral variable and add to the CSV.

Is that what you are looking for?


Markahn

October 30, 2024 at 4:17 pm

Hi Tony, thank you for your quick response which has been very helpful up to the following point. Sorry to bother you with that but I´m not able to pick out the referral_id from that resulting array in $referral. If You don´t mind would you please give me a tip?

O:8:”stdClass”:19:{s:11:”referral_id”;s:2:”34″;s:12:”affiliate_id”;s:2:”13″;s:8:”visit_id”;s:3:”134″;s:7:”rest_id”;s:0:””;s:11:”customer_id”;s:1:”0″;s:9:”parent_id”;s:1:”0″;s:11:”description”;s:15:”WAB,


Tony

  • Support Staff

October 30, 2024 at 4:30 pm

It’s not actually an array, it’s a stdClass by the looks of it so try:

echo $referral->referral_id;


Markahn

October 30, 2024 at 8:31 pm

Super! Thank You very much!


Tony

  • Support Staff

October 31, 2024 at 3:09 am

You’re most welcome 🙂

Viewing 5 reply threads

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso