• Resolved codac

    (@codac)


    Hi guys,

    in my child-theme I have added some functions in my events-manager/forms/bookingform/booking-fields.php file.
    Those functions add custom fields that the user is supposed to enter in addition to his booking.

    I would like to execute one function only when a certain category is set for the specific event.
    So I would like to know, how to get the current (opened) event-id and therefore the category-id.

    Any help is appreciated.

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Martin ter Wee

    (@martybabes)

    Stonehenge Creations

    (@duisterdenhaag)

    Hi,
    You can make a function that hooks only into the booking form. That will make it update-safe from both plugin and theme updates.

    function em_show_form_fields_for_certain_category_only() {
    	global $EM_Event;
    	$array = array();
    	$categories = $EM_Event->get_categories();
    	foreach( $categories as $category ) {
    		$array[] = (int) $category->id;
    	}
    
    	// Check if EM Category ID 3 is selected for this event.
    	if( in_array( 3, $array ) ) {
    		// Do stuff => Your custom form fields go here.
    	}
    	return;
    }
    add_action('em_booking_form_footer', 'em_show_form_fields_for_certain_category_only');
    
    Thread Starter codac

    (@codac)

    @patrick: works like a charm, thank you very much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display fields only for specific category’ is closed to new replies.