⚠️ Please Note: This tutorial is only suggested as a starting place. You'll need to customize the code examples for your own specific needs.
While we are not able to assist with custom coding, we hope this article helps you get started!
By default, only the Event Title and Event Description 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
- Customizing Required Venue Fields
- Customizing Required Organizer Fields
- Customizing Submission Error Messages
- Default Field Names
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;
}
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', 10, 1 );
function my_venue_community_required_fields( $fields ) {
if ( ! is_array( $fields ) ) {
return $fields;
}
$fields[] = 'Phone';
$fields[] = 'URL';
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', 10, 1 );
function my_organizer_community_required_fields( $fields ) {
if ( ! is_array( $fields ) ) {
return $fields;
}
$fields[] = 'email';
return $fields;
}
You can see a full list of the default fields below.
Customizing Submission Error Messages
You can add, remove, or modify Community Events submission form errors by using this filter:
- tribe_community_events_form_errors
Writing custom error messages is something rather specific to your project. It's also specific to the messages you want to display and to the fields whose lack of being filled out you want to act as triggers for messages.
So, the example code here won't actually do anything—it is simply an illustration of a basic process you could use in your customizations. You'd need to tinker and tweak from here, using var_dump() liberally, but here is a basic demonstration of the error messages filter:
add_filter( 'tribe_community_events_form_errors', 'ce_custom_error_msg' );
function ce_custom_error_msg( $errors ) {
if ( ! isset( $some_condition ) ) {
return $errors;
}
$existing_errors = '';
$type = 'error';
if ( is_array( $errors ) ) {
$existing_errors = $errors[0]['message'];
$type = $errors[0]['type'];
}
$errors[0] = array(
'type' => $type,
'message' => '<h5>You did not do something critical</h5>' . $existing_errors
);
return $errors;
}
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 (for event categories)
- venue
- organizer
- EventShowMapLink
- EventURL
🔔Quick Tip: If you have Events Calendar Pro custom fields that display 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
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.
You can also check out our Customizations overview page if you have any interest in hiring a professional developer to assist you with your project.