{"id":1896510,"date":"2019-10-18T13:19:18","date_gmt":"2019-10-18T17:19:18","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form-2\/"},"modified":"2025-01-07T14:46:13","modified_gmt":"2025-01-07T19:46:13","slug":"required-fields-for-events-submission-form","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form\/","title":{"rendered":"Required Fields for Events Submission Form"},"content":{"rendered":"\n<p class=\"has-background\" style=\"background-color:var(--global-palette8)\">This tutorial is only suggested as a starting place. You&#8217;ll need to customize the code examples for your own specific needs.<\/p>\n\n\n\n<p>By default, only the <em>Event Title<\/em> and <em>Event Description<\/em> 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&#8217;t been filled out by the submitter.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"event-fields\">Customizing required event fields<\/h2>\n\n\n\n<p>You can specify event fields for requirement by using this filter:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>tribe_events_community_required_fields<\/kbd><\/li>\n<\/ul>\n\n\n\n<p>To make the Event URL field required for submission, for example, you could add the following snippet of code to your site:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; quick-code: false; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_community_required_fields&#039;, &#039;my_community_required_fields&#039;, 10, 1 );\n\nfunction my_community_required_fields( $fields ) {\n\n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n\n  $fields&#x5B;] = &#039;EventURL&#039;;\n\n  return $fields;\n}\n<\/pre><\/div>\n\n\n<p>The <code>(required)<\/code> label should automatically be added after the field label, if the field is required.<\/p>\n\n\n\n<p>You can see a <a href=\"#default-fields\">full list of the default fields<\/a> below. It&#8217;s worth mentioning that there are also two &#8220;shortcut&#8221; fields you can specify for the <kbd>tribe_events_community_required_fields<\/kbd> filter:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>venue<\/kbd><\/li>\n\n\n\n<li><kbd>organizer<\/kbd><\/li>\n<\/ul>\n\n\n\n<p>\u261d\ufe0f These two shortcuts make the entire venue section or organizer section required, respectively. If either is added via the <kbd>tribe_events_community_required_fields<\/kbd> filter, then the user has to pick an existing venue or organizer option <strong>or<\/strong> create a new one\u2014the venue or organizer can&#8217;t be left.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"venue-fields\">Customizing required venue fields<\/h2>\n\n\n\n<p>You can specify venue fields for requirement by using this filter:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>tribe_events_community_required_venue_fields<\/kbd><\/li>\n<\/ul>\n\n\n\n<p>To make the venue URL and phone number required, for example, you could write the following snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_community_required_venue_fields&#039;, &#039;my_venue_community_required_fields&#039; );\n\nfunction my_venue_community_required_fields( $fields ) {\n    \n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n\n  $fields&#x5B;] = &#039;Phone&#039;;\n  $fields&#x5B;] = &#039;URL&#039;;\n\n  return $fields;\n}\n<\/pre><\/div>\n\n\n<p>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:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_community_required_fields&#039;, &#039;my_community_required_fields&#039; );\n \nfunction my_community_required_fields( $fields ) {\n \n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n \n  $fields&#x5B;] = &#039;venue&#039;;\n \n  return $fields;\n}\n<\/pre><\/div>\n\n\n<p>You can see a <a href=\"#default-fields\">full list of the default fields<\/a> below.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"organizer-fields\">Customizing required organizer fields<\/h2>\n\n\n\n<p>You can specify organizer fields for requirement by using this filter:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>tribe_events_community_required_organizer_fields<\/kbd><\/li>\n<\/ul>\n\n\n\n<p>To make the organizer email address required, for example, you could write the following snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_community_required_organizer_fields&#039;, &#039;my_organizer_community_required_fields&#039; );\n\nfunction my_organizer_community_required_fields( $fields ) {\n    \n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n\n  $fields&#x5B;] = &#039;Email&#039;;\n\n  return $fields;\n} \n<\/pre><\/div>\n\n\n<p>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:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_community_required_fields&#039;, &#039;my_community_required_fields&#039; );\n \nfunction my_community_required_fields( $fields ) {\n \n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n \n  $fields&#x5B;] = &#039;organizer&#039;;\n \n  return $fields;\n}\n<\/pre><\/div>\n\n\n<p>You can see a <a href=\"#default-fields\">full list of the default fields<\/a> below.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"errors\">Customizing the &#8220;(required)&#8221; label<\/h2>\n\n\n\n<p>Customizing the label is also possible through a filter. See the below example, which changes the label to &#8220;must be filled&#8221;.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_community_required_field_marker&#039;, &#039;tec_ce_custom_required_label&#039;, 10, 2 );\n\nfunction tec_ce_custom_required_label ( $html, $field ) {\n\t$html = &#039; &lt;span class=&quot;req&quot;&gt;&#039; . &#039;(must be filled)&#039; . &#039;&lt;\/span&gt;&#039;;\n\n\treturn $html;\n}\n<\/pre><\/div>\n\n\n<p>It is possible to customize the label for certain fields only. For that you can use the <code>$field<\/code> parameter that is being passed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"errors\">Customizing submission error messages<\/h2>\n\n\n\n<p>Following <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/customizing-error-messages-for-community-event-submissions\/\">this guide<\/a>, you can add, remove, or modify Community Events submission form errors.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"additional-fields\">Customizing required additional fields<\/h2>\n\n\n\n<p>If you are using <strong>Events Calendar Pro<\/strong> along with The Events Calendar, then you can make use of the <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/pro-additional-fields\/\">Additional Fields<\/a> feature to collect extra information for Events.<\/p>\n\n\n\n<p>You can make any additional field a required field by using the following example snippet.<br>Note: you will need to get the names (e.g. <code>_ecp_custom_2<\/code>) of the fields after setting them up and change them in the code.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_community_required_fields&#039;, &#039;my_community_required_fields&#039; );\n\nfunction my_community_required_fields( $fields ) {\n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n  $fields&#x5B;] = &#039;_ecp_custom_2&#039;; \/\/ this is the field name for the input you want to require\n  $fields&#x5B;] = &#039;_ecp_custom_3&#039;; \/\/ this is another input you wish to require\n  return $fields;\n}\n<\/pre><\/div>\n\n\n<p>The &#8220;required&#8221; label will not show up automatically for Additional Fields. You can fix that with the following sample snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_community_events_field_label_text&#039;, &#039;tec_additional_fields_required_labels&#039;, 10, 2 );\n\nfunction tec_additional_fields_required_labels( $text, $field ) {\n  \/\/ Bail, if it&#039;s not the Additional Field.\n\tif ( ! strstr( $field, &#039;_ecp_custom_2&#039; ) ) {\n\t\treturn $text;\n\t}\n\n  \/\/ Add the &quot;required&quot; label.\n\treturn $text . &#039; &lt;span class=&quot;req&quot;&gt;(required)&lt;\/span&gt;&#039;;\n}\n<\/pre><\/div>\n\n\n<p>The last step is to add the snippet that includes the custom field in the list of allowed fields.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tec_events_community_allowed_fields&#039;, &#039;my_community_allowed_fields&#039; );\n \nfunction my_community_allowed_fields( $fields ) {\n  if ( ! is_array( $fields ) ) {\n    return $fields;\n  }\n  $fields&#x5B;] = &#039;_ecp_custom_2&#039;;\n  return $fields;\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>\u261d\ufe0f Note: Make sure to change <strong>_ecp_custom_2&nbsp;<\/strong>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 <strong>_ecp_custom_<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"193\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/ECP-custom-1-1024x193.png\" alt=\"\" class=\"wp-image-1963105\" style=\"width:1099px;height:auto\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/ECP-custom-1-1024x193.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/ECP-custom-1-300x56.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/ECP-custom-1-768x145.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/ECP-custom-1.png 1185w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"default-fields\">Default field names (case sensitive)<\/h2>\n\n\n\n<p>These are all of the <strong>default<\/strong> Community Events submission form fields, which can be used in the filters discussed above. Please note that these field names are <strong>case-sensitive<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"default\">Default Event Fields<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>post_content<\/kbd><\/li>\n\n\n\n<li><kbd>event_image<\/kbd><\/li>\n\n\n\n<li><kbd>EventStartDate<\/kbd><\/li>\n\n\n\n<li><kbd>EventStartHour<\/kbd><\/li>\n\n\n\n<li><kbd>EventStartMinute<\/kbd><\/li>\n\n\n\n<li><kbd>EventStartMeridian<\/kbd><\/li>\n\n\n\n<li><kbd>EventEndDate<\/kbd><\/li>\n\n\n\n<li><kbd>EventEndMinute<\/kbd><\/li>\n\n\n\n<li><kbd>EventEndHour<\/kbd><\/li>\n\n\n\n<li><kbd>EventEndMeridian<\/kbd><\/li>\n\n\n\n<li><kbd>is_recurring<\/kbd><\/li>\n\n\n\n<li><kbd>EventCurrencySymbol<\/kbd><\/li>\n\n\n\n<li><kbd>tax_input.tribe_events_cat<\/kbd> <em>(for event categories)<\/em><\/li>\n\n\n\n<li><kbd>venue<\/kbd><\/li>\n\n\n\n<li><kbd>organizer<\/kbd><\/li>\n\n\n\n<li><kbd>EventShowMapLink<\/kbd><\/li>\n\n\n\n<li><kbd>EventURL<\/kbd><\/li>\n<\/ul>\n\n\n\n<p class=\"has-background\" style=\"background-color:var(--global-palette8)\"><strong>? Quick Tip:<\/strong> 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 <code>&lt;input&gt;<\/code> tag, and look for the &#8220;name&#8221; attribute (<a rel=\"noreferrer noopener\" href=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-09-08-at-8.56.17-PM.png\" target=\"_blank\">screenshot<\/a>) to specify in your array of required fields.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Default Venue Fields<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>Venue<\/kbd> <em>(the Venue Name)<\/em><\/li>\n\n\n\n<li><kbd>Address<\/kbd><\/li>\n\n\n\n<li><kbd>City<\/kbd><\/li>\n\n\n\n<li><kbd>Province<\/kbd><\/li>\n\n\n\n<li><kbd>State<\/kbd><\/li>\n\n\n\n<li><kbd>Zip<\/kbd><\/li>\n\n\n\n<li><kbd>Phone<\/kbd><\/li>\n\n\n\n<li><kbd>URL<\/kbd><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"organizer\">Default Organizer Fields<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><kbd>Organizer<\/kbd> (the organizer name)<\/li>\n\n\n\n<li><kbd>Phone<\/kbd><\/li>\n\n\n\n<li><kbd>Website<\/kbd><\/li>\n\n\n\n<li><kbd>Email<\/kbd><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>If you would like to further customize the Community Events submission forms, take a look at our <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/customizing-template-files-2\/\">Themer&#8217;s Guide<\/a> for more information on using template overrides to do so.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial is only suggested as a starting place. You&#8217;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&#8230;<\/p>\n","protected":false},"author":17,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[120],"tags":[25,58],"stellar-product-taxonomy":[152],"class_list":["post-1896510","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-community-events","tag-customizations","tag-php","stellar-product-taxonomy-community-events"],"acf":[],"taxonomy_info":{"category":[{"value":120,"label":"Event Submissions"}],"post_tag":[{"value":25,"label":"Customizations"},{"value":58,"label":"PHP"}],"stellar-product-taxonomy":[{"value":152,"label":"Community"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Andras Guseo","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/andras\/"},"comment_info":0,"category_info":[{"term_id":120,"name":"Event Submissions","slug":"community-events","term_group":0,"term_taxonomy_id":120,"taxonomy":"category","description":"","parent":61,"count":18,"filter":"raw","term_order":"0","cat_ID":120,"category_count":18,"category_description":"","cat_name":"Event Submissions","category_nicename":"community-events","category_parent":61}],"tag_info":[{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":177,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896510"}],"version-history":[{"count":11,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896510\/revisions"}],"predecessor-version":[{"id":1963861,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896510\/revisions\/1963861"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896510"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}