[AUTOMATIQUE] Cet article a plus de 5 ans.
Il se peut donc que les informations qu'il fournit ne soient plus totalement exactes.

As an improvement of my previous post regarding the customization of the the event form in the Events Manager plugin, here is what I did to improve it.

I inspected the plugin files and find some interesting hooks like em locate_template. After I understood the way it works, I plugged on it a custom function which let’s me tweak the template of the form directly from my theme.

function bweb_event_manager_booking_fields( $located, $template_name, $load, $args ){	
	if ( $template_name == 'forms/bookingform/booking-fields.php' ) {
		if ( file_exists( get_stylesheet_directory() . '/events/booking-fields.php') ) {
			$located = get_stylesheet_directory() . '/events/booking-fields.php';
		}
	}
	return $located;
}
add_filter( 'em_locate_template', 'bweb_event_manager_booking_fields', 9, 4 );

 

After you copy/paste this function in your theme functions.php file. You have to copy the file booking-fields.php which is located in /templates/forms/bookingform/ (in the Events Manager plugin) and then paste it in a new folder /events in your current theme.

Voilà, you can know improve your customization if you already have follow this post 🙂

Post written byBrice CAPOBIANCO

WordPress addict and self-taught. I love to learn and to create, then to share…
Founder of bweb.
Share this post

Your email address will not be published. Required fields are marked *

Show 4 comments

4 comments

  1. Just a follow up:
    I was able to work out how to add unlimited fields to the booking form.
    Thanks again very much for sharing your hard-earned code.
    Paul

  2. Thank you very much for such a fast response. I understand now.
    One more thing if you have a chance please.
    I am trying to add 2 more fields and have them write to the table etc.
    I’ve worked out how to double the code of the first section but am not sure which parts of the other 3 sections to repeat. I’ll keep experimenting though Brice and thanks again for your help.
    Paul

  3. Hi Brice,
    I followed your original post ‘Add custom fields to event form’ and had great success with adding one field. I was in the middle of trying to add a second field when I came across this post. I would love to be able to customise the form from the theme but do you mean from the wordpress dashboard?
    Also, I am still learning but you may have typed envents instead of events in the string of your code. I am sorry if I am wrong.
    My question is, after putting the above code in my functions.php file in my child theme, how do I then customise the form?
    Thank you for all your excellent work.
    Paul

    • Hi Paul,
      You’re right, I did a typo.
      Once you pasted the above code in your functions.php file, you have to follow this step :

      After you copy/paste this function in your theme functions.php file. You have to copy the file booking-fields.php which is located in /templates/forms/bookingform/ (in the Events Manager plugin) and then paste it in a new folder /events in your current theme.

      Then edit the file you just copied from the plugin.
      Best,