Skip to content

Instantly share code, notes, and snippets.

@Apina
Created November 11, 2014 08:35
Show Gist options
  • Save Apina/c341a2af96017f983bd3 to your computer and use it in GitHub Desktop.
Save Apina/c341a2af96017f983bd3 to your computer and use it in GitHub Desktop.
EE3 - Modified function to make additional attendees free
//Please note that this is a non supported code snippet. Event Espresso will not provide general support for it, nor may it be updated.
//Please only use as an example for your own code
function espresso_make_additional_relay_teammates_free ($ext_att_data_source) {
global $wpdb;
//As this function is called for each attendee, lets bail if it's the primary attendee.
if( $ext_att_data_source['is_primary'] == true ) {
return;
}
//add to a variable just in case
$y = $ext_att_data_source['attendee_id'];
$attendee = $wpdb->get_row("SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id= $y", ARRAY_A);
//add to a variable just in case.
$x = $attendee['registration_id'];
$teammate = $wpdb->get_row("SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id = '$x' ", ARRAY_A);
if ($teammate['is_primary'] != 1 ) {
$wpdb->update(EVENTS_ATTENDEE_TABLE,
array('final_price'=>'0.00'),
array('id'=>$teammate['id']),
array('%s'),
array('%d'));
}
}
add_action('action_hook_espresso_save_attendee_data', 'espresso_make_additional_relay_teammates_free');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment