In file event-organiser-fes/includes/actions.php, for the function function _eo_es_process_event_submission( $form ), for the case default (custom taxonomy)
Line 296 is $terms = array_map( ‘intval’, $element->get_value() );
It needs to be $terms = array_map( ‘intval’, $element->get_value(‘terms’) );
for the custom taxonomy to be saved after creating it as in the last post of this thread
https://wp-event-organiser.com/forums/topic/extending-fes-like-the-booking-form/, else the custom taxonomy won’t save.
Regards
Sadik Bhimani
Hi Sadik,
The custom taxonomy template doesn’t support creating new terms. Unless you’ve edited the template to support this, $element->get_value()
(for the custom taxonomy field) will return an array of IDs which need to be cast to integers.
Stephen Harris
Hi Stephen
Apologies I did not perhaps fully explain. I am not trying to save new taxonomy terms. I have associated a new taxonomy with the event custom post type and added the taxonomy as a drop down with wp_dropdown_categories in the template eo-event-form-custom-taxonomy.php in my child theme.
Now when I am submitting the form having selected a taxonomy from the drop down, the taxonomy actually does not get associated with the event. This is due to the missing ‘terms’ call in the code.
If I change
array_map( ‘intval’, $element->get_value() );
to
array_map( ‘intval’, $element->get_value(‘terms’) );
The taxonomy gets associated with the event. Hence I submitted this bug report.
Regards
Sadik Bhimani
I think I understand you now. wp_dropdown_categories()
, by default, will generate a different mark-up to the checklist that the template generates. In particular, the location of the selected ID(s) in the $_POST
array will be different. This isn’t a bug, with FES, you just need to ensure any changes to the template do not cause any changes to the $_POST
structure.
FES expects the the IDs of the selected terms to be array stored at:
$_POST['eventorganiser']['event_form'][<field id>]
If using wp_dropdown_categories()
to replace the default eo_fes_terms_checklist()
, the following should achieve that:
wp_dropdown_categories( array(
'taxonomy' => $this->element->get_taxonomy() . '[]',
'name' => $this->element->get_field_name(),
'hide_empty' => false,
) );
Stephen Harris