Category Menu on add listing page is not sending Drafts

Hello,

I am building a site that requires each listing to have three Categories. In order to achieve this I added a snippet that created three separate Category Menus on the “add listing” page". On the front end, everything works correct and three separately labeled Category menus show up with the correct drop down options.

When a listing is submitted though, only the first category the user selected is sent to me as a draft. In other words, a user selects three categories, and only one is sent back to me.

I would like to fix this and create a system in which all three categories are sent back to me. What are some possible solutions or workarounds?

These are the two code snippets I have activated:

  1. This snippet adds three category menus. The menus display all subcategories with the corresponding Term ID’s:
add_filter(
    'hivepress/v1/forms/listing_submit',
    function( $form ) {

        // Fetching subcategories for Injuries
        $injury_subcategories = get_terms([
            'taxonomy'   => 'hp_listing_category',
            'include'    => [XX, YY], // Replace with the actual term IDs of the subcategories under "Injuries"
            'hide_empty' => false,
        ]);

        $injury_options = [];
        foreach ($injury_subcategories as $term) {
            $injury_options[$term->term_id] = $term->name;
        }

        $form['fields']['injuries_category'] = [
            'type'     => 'select',
            'options'  => $injury_options,
            'label'    => esc_html__( 'Injuries', 'hivepress' ),
            'required' => true,
        ];

        // Fetching subcategories for Cases
        $cases_subcategories = get_terms([
            'taxonomy'   => 'hp_listing_category',
            'include'    => [XX, YY], // Replace with the actual term IDs of the subcategories under "Cases"
            'hide_empty' => false,
        ]);

        $cases_options = [];
        foreach ($cases_subcategories as $term) {
            $cases_options[$term->term_id] = $term->name;
        }

        $form['fields']['cases_category'] = [
            'type'     => 'select',
            'options'  => $cases_options,
            'label'    => esc_html__( 'Cases', 'hivepress' ),
            'required' => true,
        ];

        // Fetching subcategories for Location
        $location_subcategories = get_terms([
            'taxonomy'   => 'hp_listing_category',
            'include'    => [XX, YY], // Replace with the actual term IDs of the subcategories under "Location"
            'hide_empty' => false,
        ]);

        $location_options = [];
        foreach ($location_subcategories as $term) {
            $location_options[$term->term_id] = $term->name;
        }

        $form['fields']['location_category'] = [
            'type'     => 'select',
            'options'  => $location_options,
            'label'    => esc_html__( 'Location', 'hivepress' ),
            'required' => true,
        ];

        return $form;
    },
    1000
);
  1. This second Snippet Removes the original Category Menu:
add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
		unset($form['fields']['categories']);	

		return $form;
	},
	990
);

Hi,

Sorry for the inconvenience, but customization is beyond our support scope - it includes fixing bugs and guidance about the available features. Support Policy | HivePress

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.