This tutorial is only suggested as a starting place. You’ll need to customize the code examples for your own specific needs.

By default, only the Event Title and Event Description fields are required on the Community Events submission form. But you can use plugin filters to modify what fields are required and/or what error messages display when a required field hasn’t been filled out by the submitter.


Customizing required event fields

You can specify event fields for requirement by using this filter:

  • tribe_events_community_required_fields

To make the Event URL field required for submission, for example, you could add the following snippet of code to your site:

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[] = 'EventURL';

  return $fields;
}

The (required) label should automatically be added after the field label, if the field is required.

You can see a full list of the default fields below. It’s worth mentioning that there are also two “shortcut” fields you can specify for the tribe_events_community_required_fields filter:

  • venue
  • organizer

☝️ These two shortcuts make the entire venue section or organizer section required, respectively. If either is added via the tribe_events_community_required_fields filter, then the user has to pick an existing venue or organizer option or create a new one—the venue or organizer can’t be left.


Customizing required venue fields

You can specify venue fields for requirement by using this filter:

  • tribe_events_community_required_venue_fields

To make the venue URL and phone number required, for example, you could write the following snippet:

add_filter( 'tribe_events_community_required_venue_fields', 'my_venue_community_required_fields' );

function my_venue_community_required_fields( $fields ) {
    
  if ( ! is_array( $fields ) ) {
    return $fields;
  }

  $fields[] = 'Phone';
  $fields[] = 'URL';

  return $fields;
}

In order for the above snippet to work, it is necessary to also require the venue field itself. You can do that with the following snippet:

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

You can see a full list of the default fields below.


Customizing required organizer fields

You can specify organizer fields for requirement by using this filter:

  • tribe_events_community_required_organizer_fields

To make the organizer email address required, for example, you could write the following snippet:

add_filter( 'tribe_events_community_required_organizer_fields', 'my_organizer_community_required_fields' );

function my_organizer_community_required_fields( $fields ) {
    
  if ( ! is_array( $fields ) ) {
    return $fields;
  }

  $fields[] = 'Email';

  return $fields;
} 

In order for the above snippet to work, it is necessary to also require the organize field itself. You can do that with the following snippet:

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

You can see a full list of the default fields below.


Customizing the “(required)” label

Customizing the label is also possible through a filter. See the below example, which changes the label to “must be filled”.

add_filter( 'tribe_community_required_field_marker', 'tec_ce_custom_required_label', 10, 2 );

function tec_ce_custom_required_label ( $html, $field ) {
	$html = ' <span class="req">' . '(must be filled)' . '</span>';

	return $html;
}

It is possible to customize the label for certain fields only. For that you can use the $field parameter that is being passed.

Customizing submission error messages

Following this guide, you can add, remove, or modify Community Events submission form errors.


Customizing required additional fields

If you are using Events Calendar Pro along with The Events Calendar, then you can make use of the Additional Fields feature to collect extra information for Events.

You can make any additional field a required field by using the following example snippet.
Note: you will need to get the names (e.g. _ecp_custom_2) of the fields after setting them up and change them in the code.

add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields' );

function my_community_required_fields( $fields ) {
  if ( ! is_array( $fields ) ) {
    return $fields;
  }
  $fields[] = '_ecp_custom_2'; // this is the field name for the input you want to require
  $fields[] = '_ecp_custom_3'; // this is another input you wish to require
  return $fields;
}

The “required” label will not show up automatically for Additional Fields. You can fix that with the following sample snippet:

add_filter( 'tribe_community_events_field_label_text', 'tec_additional_fields_required_labels', 10, 2 );

function tec_additional_fields_required_labels( $text, $field ) {
  // Bail, if it's not the Additional Field.
	if ( ! strstr( $field, '_ecp_custom_2' ) ) {
		return $text;
	}

  // Add the "required" label.
	return $text . ' <span class="req">(required)</span>';
}

The last step is to add the snippet that includes the custom field in the list of allowed fields.

add_filter( 'tec_events_community_allowed_fields', 'my_community_allowed_fields' );
 
function my_community_allowed_fields( $fields ) {
  if ( ! is_array( $fields ) ) {
    return $fields;
  }
  $fields[] = '_ecp_custom_2';
  return $fields;
}

☝️ Note: Make sure to change _ecp_custom_2 to a field that you are using on your submission form. You can find it by inspecting your site in the browser console and searching for _ecp_custom_.


Default field names (case sensitive)

These are all of the default Community Events submission form fields, which can be used in the filters discussed above. Please note that these field names are case-sensitive.

Default Event Fields

  • post_content
  • event_image
  • EventStartDate
  • EventStartHour
  • EventStartMinute
  • EventStartMeridian
  • EventEndDate
  • EventEndMinute
  • EventEndHour
  • EventEndMeridian
  • is_recurring
  • EventCurrencySymbol
  • tax_input.tribe_events_cat (for event categories)
  • venue
  • organizer
  • EventShowMapLink
  • EventURL

? Quick Tip: If you are using Events Calendar Pro custom fields on the form, then you can even specify these fields as required. Just view the HTML source and find the correct <input> tag, and look for the “name” attribute (screenshot) to specify in your array of required fields.

Default Venue Fields

  • Venue (the Venue Name)
  • Address
  • City
  • Province
  • State
  • Zip
  • Phone
  • URL

Default Organizer Fields

  • Organizer (the organizer name)
  • Phone
  • Website
  • Email

If you would like to further customize the Community Events submission forms, take a look at our Themer’s Guide for more information on using template overrides to do so.