Help Desk

Setting Categories Field to Required When Submitting an Event

  • Posts: 3 Topics: 4
    | Permalink

    Hello,

    I am setting fields in the input screen to required. I followed the instructions here: https://theeventscalendar.com/knowledgebase/required-fields-for-events-submission-form/

    I am not successful in setting the EVENT CATEGORIES field to required. The only reference to Categories that I saw was

    tax_input (for event categories)

    My code:

    add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields', 10, 1 );
    
    function my_community_required_fields( $fields ) {
    
        if ( ! is_array( $fields ) ) {
            return $fields;
        }
    
        $fields[] = 'EventStartDate';
        $fields[] = 'tax_input';
    
        return $fields;
    }

    I was successful setting the Date field.

    Many thanks,
    Yehuda

    Posts: 4918
    | Permalink
    Correct Answer

    Hi Yehuda,

    I’m sorry that code isn’t working for you…can you try the following instead and see if it works? I just tested it out on my end, and it does set the category field to required. We are in the process now of updating the knowledge article you referenced with the new code:

    add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields' );
    function my_community_required_fields( $fields ) {
       if ( is_array( $fields ) ) {
          $fields[] = 'tax_input.tribe_events_cat';
          $fields[] = 'EventStartDate';
       }
       return $fields;
    }

    Let me know if that helps!

    Thanks,

    Jennifer

    Posts: 3 Topics: 4
    | Permalink

    Hello Jennifer,

    That was it.

    Many thanks!
    Yehuda

    Posts: 4918
    | Permalink

    Perfect! I’m glad to hear that worked for you. I’ll go ahead and close out this thread, but please feel free to open up a new one if you have any other questions!

    Thanks,

    Jennifer

The topic ‘Setting Categories Field to Required When Submitting an Event’ is closed to new replies.