snippet.host

minimal text and code snippet hosting

welcome, guest. why not login or register?
created: 5 months ago language: php views: 41 size: 4.23 KiB lines: 126 clone raw download
add_filter('eventorganiser_pro_get_option_disable_automatic_form', '__return_true'); // Removes Event Organiser auto generated form
add_filter('eventorganiser_notify_confirmed_booking', '__return_false'); // Disables confirmation email (Use it for migrating bookings)
add_filter('manage_event_page_bookings_columns', 'banana__wpe_booking_columns', 15 );
add_action('eventorganiser_booking_table_column', 'banana__wpe_booking_column_content', 10, 2);
add_action('eventorganiser_pre_gateway_booking', 'banana__dont_autoconfirm_free_bookings', 9999);

function banana__wpe_booking_columns($columns) {

unset($columns['booking_price']);
$columns['additional'] = "Additional info";
return $columns;

}


function banana__wpe_booking_column_content($column_name, $item) {

$job = eo_get_booking_meta($item->ID, 'meta_5', true);
$org = eo_get_booking_meta($item->ID, 'meta_4', true);
$dietary = eo_get_booking_meta($item->ID, 'meta_7', true);
$borough = eo_get_booking_meta($item->ID, 'meta_14', true);
$postcode = eo_get_booking_meta($item->ID, 'meta_6', true);
$notes = eo_get_booking_meta($item->ID, 'meta_10', true);
$access = eo_get_booking_meta($item->ID, 'meta_12', true);
$pa = eo_get_booking_meta($item->ID, 'meta_11', true);

if ($column_name == 'additional') {

echo '<small>Job: ' . $job . '<br>Org: ' . $org . '<br>Access: ' . $access . '<br>PA: ' . $pa . '<br>Borough: ' . $borough . '<br>Postcode: ' . $postcode . '<br>Dietary: ' . $dietary. '<br>Notes: ' . $notes . '</small>';

}

}


function banana__dont_autoconfirm_free_bookings($booking_id) {

$total_price = eo_get_booking_meta( $booking_id, 'booking_amount');
if (0 == $total_price) {

//Redirect to 'thank you page' - you can change $redirect_id as required here:
$redirect_id = (int) eventorganiser_pro_get_option('booking_redirect');
$redirect = get_permalink( $redirect_id );

wp_redirect( esc_url_raw( $redirect ) );
exit();
}

}


// Defaults ticket amount to 1 instead of 0

add_action('eventorganiser_get_event_booking_form', function($form_id, $event_id) {

$tickets = eo_get_event_tickets_on_sale($event_id);

if (isset($_POST['eventorganiser']['booking']['tickets'])) {
return;
}

$_POST['eventorganiser']['booking']['tickets'] = array();
$i = 0;
foreach ($tickets as $tt_id => $ticket) {
//Set default quantity below
if ($i == 0) {
$_POST['eventorganiser']['booking']['tickets'][$tt_id] = 1;
} else {
$_POST['eventorganiser']['booking']['tickets'][$tt_id] = 0;
}
$i++;
}

}, 10, 2);


// Change event booking from email
// Source: http://docs.wp-event-organiser.com/bookings/notification-emails/

/*
function banana__event_admin_email($email){

$email = 'hidden@example.com';
return $email;

}
add_filter('eventorganiser_admin_email', 'banana__event_admin_email');
*/

function banana__booking_notification_email($emails, $booking_id){

//Get the event ID and organiser ID
$event_id = eo_get_booking_meta($booking_id, 'event_id');

//Get the event's organiser
$organiser_id = get_post_field('post_author', $event_id);
$user_obj = get_userdata($organiser_id);

//If the user exists, add their email to notify both organiser and admin
if($user_obj){
$emails[] = $user_obj->user_email;
}

$emails[] = 'hidden@example.com';
return $emails;

}
// add_filter('eventorganiser_booking_notification_email', 'banana__booking_notification_email', 10, 2);


add_filter('eventorganiser_export_bookings_headers', function( $columns ) {
$columns['ticket_types'] = 'Ticket types';
return $columns;
} );


add_filter('eventorganiser_export_bookings_cell_ticket_types', function($cell, $booking, $export) {
$tickets = eo_get_booking_tickets($booking->ID, false);
$cell = '';
if ($tickets){
$ticket_names = wp_list_pluck($tickets, 'ticket_name');
$cell = implode(', ', $ticket_names);
}
return $cell;
}, 10, 3);