Hi Stephen,
Just bought the plugin and must say that I really like it! One thing I’m not able to figure out though, is how I can prevent the free (€0) bookings to automatically confirm. I want to be able to confirm that someone is allowed to attend.
Is this a setting in the UI I overlooked? Or do you have any ideas on how this can be done using code?
— Laurent

Laurent van Dommelen
Hi Laurent,
Glad you like the plug-in! There’s no UI setting you’ve over-looked, that’s just default behaviour.
You can change that with the following snippet:
add_action( 'eventorganiser_pre_gateway_booking', 'my_dont_autoconfirm_free_bookings', 9999 );
function my_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();
}
}
(that should go in a site utility plug-in: http://wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/)

Stephen Harris
Thank you sir, so quick, so accurate. Perfect! Keep up the good work.

Laurent van Dommelen
Hi Stephen,
the code snippet works not proper in my situation.
It is placed in a site utility plugin and activated.
After the activation i get a blank page after submitting a booking request.
I would like to redircet the user to the event page.
I hope you can help me! Thanks!

Tobias
Hi Tobias,
Sounds like there’s some sort of fatal error. What do your error logs say? (Or turn on WP_DEBUG, and it should print it to the screen).

Stephen Harris
Hi Stephen,
I enabled the WP_DEBUG, but no error log are created. I get an empty html responste with an emty body tag. Is there something I need to change for the redirect_id?
$redirect_id = (int) eventorganiser_pro_get_option( 'booking_redirect' );
$redirect = get_permalink( $redirect_id );
wp_redirect( esc_url_raw( $redirect ) );
exit();

Tobias
Assuming $redirect_id
is the ID of a page/post, then I don’t see anything wrong with that. What you’ve posted is fine, so I can’t really advise on why you’re getting a white screen.

Stephen Harris
Hi Stephen,
I hope you are well! The code doesn’t work for me either. Appointments with a cost of zero euros are automatically set to Confirmed. I haven’t changed anything in your code because the redirect should be taken from the plugin settings. I can’t see any logic in the function to prevent the automatic confirmation either, except for the redirect. Is that right? Thank you for your help!

Andreas Junge