Thanks, Stephen.
The next mini-challenge I face: my plugin lists a user’s bookings (per your suggestions in the source), and I’ve tweaked it so that it lists each event in a link so that you can click to go to the event page (to remind yourself where it’s taking place, for example).
Of course, if you click on the link, you’re presented with the event, with the booking form below it, and an advisory saying “you have already made a booking for this event”. I’m looking for a way to suppress the whole booking form if a user has already booked for it. I’ve found eo_user_has_bookings
in user-bookings.php, which I guess is the function I need to run to determine whether or not to switch off the booking form – but I can’t see how to turn off the booking form itself. Could you give me a clue, please?
Thanks as always!
John
s2dd
I split this off from http://wp-event-organiser.com/forums/topic/pro-allow-bookees-to-see-their-bookings/ as its an interesting question in its own right.
You can hook onto init
, and conditionally call:
add_filter( 'eventorganiser_pro_get_option_disable_automatic_form', '__return_true' );
to remove the booking section.
Stephen Harris
So, scrap that. That needs to be called much earlier than init
Instead hook onto the template_redirect
hook (this is late enough, but not too late). And using eo_user_has_bookings( $user_id, get_the_ID())
you can call
remove_filter( 'the_content', 'eventorganiser_display_booking_table', 999 );
In a 2.1.1 you can use the above method instead (which would be preferable).
Stephen Harris
Brilliant – that works a treat. Thank you!
s2dd