0

I was trying to make the "name field" & "phone field" in the events booking form a required field as well and I managed to look for some answers from here --> https://wordpress.org/support/topic/booking-form-required-fields?replies=13. Have also added the below codes into my child theme functions.php. On the single event page (with the booking form), after clicking on the "Send your booking" (without entering anything into the fields), error message still shows only "ERROR: Please type your e-mail address." only. Is there any steps I'm missing here? Have anyone experience the same issue before and could anyone point me in the right direction?

function em_validate($result, $EM_Event){
if (!is_user_logged_in() && $_REQUEST['user_name'] == ''){
    $EM_Event->add_error('Your Name is Required...');
    $result = false;
}
if (!is_user_logged_in() && $_REQUEST['dbem_phone'] == ''){
    $EM_Event->add_error('Your Contact Number is Required...');
    $result = false;
}
if (!is_user_logged_in() && $_REQUEST['user_email'] == ''){
    $EM_Event->add_error('Your Email is Required...');
    $result = false;
}
return $result;
}
add_filter('em_event_validate','em_validate', 1, 2);

2 Answers 2

2

I manage to get the answers from this post --> https://wordpress.org/support/topic/change-required-fields-in-registration-form?replies=3

Instead of using 'em_event_validate'

add_filter('em_event_validate','em_validate', 1, 2);

should be using 'em_booking_validate' in the filter hook

add_filter('em_booking_validate','em_validate', 1, 2);
0

I found a way to make those fields required with html required attribute. Search for booking-fields.php and make a copy to add it here: your-child-theme\plugins\events-manager\forms\bookingform\ , create each folder needed for that path ... Then within this copy of booking-form.php edit the code:

<input type="text" maxlength="50" required name="user_name" id="user_name" class="input" value="<?php if(!empty($_REQUEST['user_name'])) echo esc_attr($_REQUEST['user_name']); ?>" /> 

You have now a 'safe-upgrade' customisation of EM plugin. This works with all files inside the plugin's 'template' folder / copy-to=> your-child-theme\plugins\events-manager\

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.