Hi Stephen,
Sorry, another problem I’m facing… How do I correctly implement “Last Name” (lname) within eo-bookee-details to be a required field? The same as “First Name” and “E-mail”. There does not appear to be any native option/setting to implement. I would appreciate your advice on how to correctly implement (or hack… :o) ), so I can manage throughout future versions etc…
Many Thanks
Jason

jasonb
Hi Jason,
Not so much a hack as using the available booking form API (which is currently being documented). It uses the eventorganiser_validate_booking_submission
hook which runs after a booking is submitted by the user, and is being checked for errors. If $errors
contains any errors, the user is returned to the form with these displayed:
function _my_validate_booking_submission_conditions( $input, $form, $errors ){
//Names and email don't currently appear in $input.
$lname = isset( $_POST['lname'] ) ? $_POST['lname'] : '';
//If user is not logged and last name is not provdied, add an error
if( !is_user_logged_in() && !$lname ){
//If any errors are added to $errors, it will return the user to the booking form
//with the errors displayed:
$errors->add( 'missing_last_name', 'Please provide a last name' );
}
//You must return what you've been given!
return $input;
}
add_filter( 'eventorganiser_validate_booking_submission', '_my_validate_booking_submission_conditions', 11, 3 );
As always, best use this in a utility plug-in, but it will work in your theme’s functions.php
(wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/)
Hope that helps!
-
This reply was modified 11 years, 3 months ago by
Stephen Harris. Reason: Corrected error

Stephen Harris
I have a similar problem. The provided solution posted above makes the field “last name” a required field but it doesn’t indicate it with a star character ‘*’
Is there a solution to add span class “required eo-booking-form-required” to the field ‘last name’
Thanks in advance
Jan

Jan Wildefeld
Hi Jan,
Currently the only way of doing this is to copy the eo-booking-form.php
template into your theme and edit it. Specifically, it contains a call to eo_signup_form()
(which can be found in includes / booking-form-handler.php
). If you replace eo_signup_form()
with the (edited) mark-up of eo_signup_form()
, then you can add the necessary class and *
.
At some point, these ‘sign-up’ fields will may become part of the customiser (with appropriate checks to ensure backwards compatibility).

Stephen Harris
Anyone following this please note there was an error in my original post which has now been fixed.
Changes:
add_action
was changed to add_filter
– (but this doesn’t actually matter)
return $input
was added — this is the important change.
If you’re running the old code you’ll probably experience a white-screen, or, in debug mode, a message along the lines of “Invalid argument supplied for foreach() “.
Apologies for the error

Stephen Harris