
Stephen Harris
Hi David,
Each field added to the form as an ID, you can get the associated data via:
$value = eo_get_booking_meta( $booking_id, $element_id, true );

David McCourt
Appreciate the quick response. Thanks Stephen, that works.
Final question: how to get the booking form additional fields? I can’t get any of these to work:
$org = get_post_meta($item->ID, 'organisation');
or
$org = eo_get_booking_meta($item->ID, 'organisation');
or
$event_id = eo_get_booking_meta($item->ID, 'event_id');
$org = get_post_meta($event_id, 'organisation');
or
$event_id = eo_get_booking_meta($item->ID, 'event_id');
$org = eo_get_booking_meta($event_id, 'organisation');
Thanks!

Stephen Harris
Hi Per,
I’ve not been able to replicate this. How are you using the shortcode? Just in page/post content?
This could be a conflict with another plug-in (or some custom code). As an example, I recently saw something similar where a user had created an [email]
shortcode, and had added the line:
add_filter( 'the_content', 'do_shortcode' );
This passed the HTML content of the event (containing the booking form) through do_shortcode
and meant HTML containing [email]
(e.g. <input name="eo_booking[email]"...>
) was altered, and caused the booking form to always reject a booking because no email was provided.
While I don’t think that exact same thing is happening here, the point is that anything acting on the the_content
could potentially cause this. If you’re not aware of any custom code you’ve added yourself that might cause this, then I’d recommend deactivating other plug-ins to identify if there is a conflict. If there is, I’d be happy to take a look to see if they problem can be worked around.

Per Soderlind
The shortcode [event_booking_form event_id="181"]
returns the following garbled content:
http://blogg.regjeringen.no/euikt15/pamelding-til-euikt15/

Alex Steer
Thanks for your reply Stephen.
Is it possible to get a working example of this filter?
I have located the html
$booking_table = sprintf(
'<table style="width:100%%;text-align:center;">
<thead style="font-weight:bold;"><tr> <th>%s</th><th> %s </th> <th>%s</th></tr></thead>
<tbody>',
__( 'Ticket', 'eventorganiserp' ),
__( 'Price', 'eventorganiserp' ),
__( 'Ref.', 'eventorganiserp' )
);
foreach ( $booking_tickets as $ticket ) {
$booking_table .= sprintf(
'<tr> <td>%s<td> %s </td> <td>%s</td></tr>',
esc_html( $ticket->ticket_name ),
eo_format_price( $ticket->ticket_price ),
$ticket->ticket_reference
);
}
$booking_table .= apply_filters( 'eventorganiser_email_ticket_list_pre_total', '', $booking_id );
$booking_table .= sprintf( '<tr> <td>%s</td><td> %s </td> <td></td></tr></tbody></table>', __( 'Total', 'eventorganiserp' ), eo_format_price( $total_price ) );

Stephen Harris
Yup:
add_filter( 'eventorganiser_settings_tabs',function( $tabs ){
unset( $tabs['bookings'] );
unset( $tabs['booking-form'] );
return $tabs;
}, 20 );

Clifford P
My mistake. For some reason it now works to make Events -> Bookings submenu page removed from the wp-admin menu (/wp-admin/edit.php?post_type=event&page=bookings) and the Event Tickets metabox go away from the Event post type wp-admin page.
However, Settings -> Event Organiser -> “Bookings” (/wp-admin/options-general.php?page=event-settings&tab=bookings) and “Booking Form” (/wp-admin/options-general.php?page=event-settings&tab=booking-form) tabs still appear.
Is there a way to remove those as well?

Stephen Harris
Hi Dan,
As you’re aware the plug-in doesn’t add a second, ‘confirm your e-mail’ field (perhaps it should), but you can do it with the following:
function my_add_element( $form, $event_id ){
//Get existing email field
$email = $form->get_element( 'email' );
if( !$email ){
return;
}
//Create element to add to the field
$element = EO_Booking_Form_Element_Factory::create( array(
'type' => 'email',
'id' => '_confirm_email', //a unique ID
'required' => 1, //make this field required
'label' => 'Please confirm your e-mail'
) );
//Add the field element, immediately below $email field
$form->add_element( $element, array(
'at' => $email->get( 'position' ) + 1,
'parent' => $email->get_parent()
) );
}
add_action( 'eventorganiser_get_event_booking_form', 'my_add_element', 10, 2 );
Code to validate confirmed e-mail address
function my_validate_element( $form ){
$email= $form->get_element( 'email' );
$email2 = $form->get_element( '_confirm_email' );
if( $email && $email->get_value() !== $email2->get_value() ){
$email2->add_error( 'email-mismatch', "Emails do not match." );
}
}
add_filter( 'eventorganiser_validate_booking_form_submission', 'my_validate_element', 10 );

Dan Skinner
Following an event that we’ve just held, we heard from a few too many people that they hadn’t received the confirmation email. This could obviously have been for a number of reasons, but as I’m not insisting that they register an account, I’d like to be sure that they’ve at least entered a valid email address.
Is there a way of adding a second ‘verify Email’ field to a booking form that won’t allow people to submit the booking until the 2 emails entered match?

Stephen Harris
Yes, the documentation is lacking at the moment, but you can specify the position in a settings array. You an also specify a parent (for elements which allow nested elements – currently only fieldset elements).
$form->add_element( $checkbox, array(
'at' => $position, //integer
'parent' => $parent_element, //instance of iEO_Booking_Form_Element_Parent
);
Of course, you need to determine the appropriate $position
and $parent_element
. You can do this by using an existing element (e.g. the submit button) to position this new element relative to that element.
Here’s an example which places a checkbox just before the submit button:
add_action( 'eventorganiser_get_event_booking_form', 'add_field_to_booking_form', 10, 2 );
function add_field_to_booking_form( $form, $event_id ){
//Create a field
$checkbox = EO_Booking_Form_Element_Factory::create( array(
'type' => 'checkbox',
'id' => 'my-unique-id', //Must be unique in the form. You should not use 'name', 'ticketpicker', 'gateway' or 'email' as an ID,
'label' => 'Select an option:',
'options' => array( 'A' => 'Option A', 'B' => 'Option B', 'C' => 'Option C' ),
'required' => true, //Default is false
'description' => "Pick one of the options",
) );
$submit = $form->get_element( 'submit' );
$position = intval( $submit->get( 'position' ) ); //position of submit button.
$parent = $submit->get_parent(); //parent of submit button
$form->add_element( $checkbox, array(
'at' => $position,
'parent' => $parent_element,
);
}
Just an explanatory note about the ‘at’ setting. The added element is inserted at that position. Any existing element in that position is moved forward (i.e. pushed down the form). If you wanted to add something immediately after the submit button you would at it at $postion + 1
.
Hope that helps!

B+eo
What a great release of the latest event-organiser plugins … I was very pleased to see a eo_get_the_occurrence_id() and the booking-form enhancements.
But I have one question. If I add a custom form element to the default booking-form it gets displayed below the submit button.
I added the custom element via add_action( 'eventorganiser_get_event_booking_form', 'add_field_to_booking_form', 10, 2 );
as explained under http://wp-event-organiser.com/blog/announcements/event-organiser-pro-1-10-0/.
How can I put this element above the submit button?
-
This topic was modified 10 years, 3 months ago by
B+eo.

Stephen Harris
Hi Alex,
Yes, as of 1.10.0 you can do the following:
add_action( 'eventorganiser_get_event_booking_form', 'my_set_address_labels', 10, 2 );
function my_set_address_labels( $form, $event_id ){
$labels = array(
'street-address' => __( 'Street Address', 'eventorganiserp' ),
'2nd-line' => __( 'Address Line 2', 'eventorganiserp' ),
'city' => __( 'City', 'eventorganiserp' ),
'state' => __( 'Region/County', 'eventorganiserp' ),
'postcode' => __( 'Postcode', 'eventorganiserp' ),
'country' => __( 'Country', 'eventorganiserp' ),
);
$elements = $form->flatten_elements();
foreach( $elements as $element ){
if( 'address' == $element->type ){
$element->set( 'subfield_labels', $labels );
}
}
}
to change the labels. To change the placeholder you’d need to edit the template (eo-booking-form-address.php
in event-organiser-pro/templates/booking-form/
)

Michael Waugaman
it’s in functions.php
am aware of advice regarding using a utility but in our situ our theme is not going anywhere 😉

Michael Waugaman
Hi Stephen – hope you’re keeping well 🙂
We are trying to customise our Thank You message on the booking form for those who pay via paypal. I’ve read the following resources:
http://wp-event-organiser.com/forums/topic/thank-you-message/ and http://docs.wp-event-organiser.com/bookings/changing-the-thank-you-message/ and set up a filter accordingly:
add_filter( 'eventorganiser_pro_get_option_booking_complete_message_paypal', 'paypal_booking_complete' );
function paypal_booking_complete(){
return 'Thank you for your booking. You will receive an invoice and confirmation of your booking shortly.';
}
but we’re having no joy …..perhaps you can see what I’m missing?
(http://www.stjohnschambers.co.uk/events/personal-injury-update-2015/