Overview

If you’re using Community Events and want to prevent users from selecting certain event categories when submitting events through the frontend submission form, you can use a custom code snippet to exclude specific category IDs from the category dropdown.

This is helpful if you use categories internally or want to limit what contributors can assign to their events.

Steps to Exclude Categories

Add the following snippet to your site’s theme functions.php file or use a plugin like Code Snippets plugin:

add_filter(
    'tribe_dropdown_search_terms',
    function( $data, $search, $page, $args, $source ) {

        // Only apply this to event categories
        if ( 'tribe_events_cat' !== $args[ 'taxonomy' ] ) {
            return tribe( 'ajax.dropdown' )->search_terms( $search, $page, $args, $source );
        }

        $exclude_ids = '4'; // Replace with your category ID(s) to exclude

        // If no exclude is set, create one
        if ( ! isset( $args[ 'exclude' ] ) ) {
            $args['exclude'] = $exclude_ids;
        } else {
            // Convert to array if needed
            if ( ! is_array( $args['exclude'] ) ) {
                $args['exclude'] = explode( ',', $args['exclude'] );
            }

            // Merge with existing excluded IDs
            $args['exclude'] = array_merge( $args['exclude'], (array) $exclude_ids );
        }

        // Return modified dropdown
        return tribe( 'ajax.dropdown' )->search_terms( $search, $page, $args, $source );
    },
    10,
    5
);

Notes

  • Replace 4 in $exclude_ids = '4'; with the ID of the category you want to hide. You can also pass multiple IDs separated by commas (e.g., '4,12,15').
  • This affects only the dropdown in the Community Events submission form. It does not affect the backend or public display of events.

How to Find Category IDs

To find a category ID:

  1. Go to WP Admin Dashboard → Events Event Categories.
  2. Hover over a category name and look at the URL preview in your browser’s status bar. The tag_ID in the URL is the category ID as shown below:

By using this filter, you can have more control over what options are available to event submitters and keep internal or restricted categories hidden from view.