{"id":1963464,"date":"2025-01-07T14:43:58","date_gmt":"2025-01-07T19:43:58","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/?p=1963464"},"modified":"2025-07-14T13:25:57","modified_gmt":"2025-07-14T17:25:57","slug":"customizing-error-messages-for-community-event-submissions","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/customizing-error-messages-for-community-event-submissions\/","title":{"rendered":"Customizing Error Messages for Community Event Submissions"},"content":{"rendered":"\n<p>By default, the only fields required when submitting an event through the Community plugin are &#8216;Title&#8217; and &#8216;Description&#8217;, though you can also set other fields as required with <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form\/\">this guide<\/a>. If you would like to customize the error messages displayed to a user when a required field is missing, this is possible through the process we&#8217;ll cover in this guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-changing-error-messages-for-default-required-fields\">Changing Error Messages for Default Required Fields<\/h2>\n\n\n\n<p>First, let&#8217;s understand where these error messages are coming from. If you go to your Event Submission page and try to submit an event without a title and description, you can use <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/using-google-chrome-developer-tools\/\">Chrome Dev Tools<\/a> to inspect the page and use the console to enter <code>tribe_submit_form_i18n<\/code> . This will show the object <code>errors<\/code> where all the errors are stored. They all have <code>key-value<\/code> pair &#8211; in this case the <code>key<\/code> is the label for the field and the <code>value<\/code> is the error message to be output.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"365\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.21.41@2x-1024x365.png\" alt=\"\" class=\"wp-image-1963470\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.21.41@2x-1024x365.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.21.41@2x-300x107.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.21.41@2x-768x274.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.21.41@2x-1536x547.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.21.41@2x-2048x729.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Since these errors are added through a script, we can use a snippet that modifies the script to update error messages:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_action( &#039;wp_enqueue_scripts&#039;, function ( ) {\n\/\/ Ensure the script is enqueued\n\twp_enqueue_script( &#039;tribe_events-community&#039; );\n\n\/\/ Modify the localization data\n\twp_add_inline_script( &#039;tribe_events-community&#039;, &#039;\n        if ( tribe_submit_form_i18n.errors&#x5B; &quot;post_title&quot; ] ) { \/\/ Tweak to match which field you want to change\n        tribe_submit_form_i18n.errors&#x5B; &quot;post_title&quot; ] = &quot;You cannot submit an event without a title&quot;; \/\/ Tweak to match what message you want to output\n        }\n    &#039;, &#039;before&#039; );\n}, 20 );\n<\/pre><\/div>\n\n\n<p>Here is how that would affect the frontend: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"363\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.30.15@2x-1024x363.png\" alt=\"\" class=\"wp-image-1963471\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.30.15@2x-1024x363.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.30.15@2x-300x106.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.30.15@2x-768x272.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.30.15@2x-1536x545.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.30.15@2x-2048x726.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s add to the Event Description to the same example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_action( &#039;wp_enqueue_scripts&#039;, function ( ) {\n\t\t\/\/ Ensure the script is enqueued.\n\t\twp_enqueue_script( &#039;tribe_events-community&#039; );\n\n\t\t\/\/ Modify the localization data.\n\t\twp_add_inline_script(\n\t\t\t&#039;tribe_events-community&#039;,\n\t\t\t&#039;if ( tribe_submit_form_i18n.errors&#x5B;&quot;post_title&quot;] ) { \n        tribe_submit_form_i18n.errors&#x5B; &quot;post_title&quot; ] = &quot;You cannot submit an event without a title&quot;; \n        }\n        if ( tribe_submit_form_i18n.errors&#x5B; &quot;tcepostcontent&quot; ] ) { \n        tribe_submit_form_i18n.errors&#x5B; &quot;tcepostcontent&quot; ] = &quot;Please add an event description \ud83d\ude48&quot;; \n        }&#039;,\n\t\t\t&#039;before&#039; \n\t\t);\n\t}\n);\n<\/pre><\/div>\n\n\n<p>And here is how that would affect the frontend: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"443\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.38.30@2x-1024x443.png\" alt=\"\" class=\"wp-image-1963472\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.38.30@2x-1024x443.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.38.30@2x-300x130.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.38.30@2x-768x333.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.38.30@2x-1536x665.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/11\/CleanShot-2024-11-22-at-16.38.30@2x-2048x887.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-changing-error-messages-for-custom-required-fields\">Changing Error Messages for Custom Required Fields<\/h2>\n\n\n\n<p>In the case where you have set up requiring fields other than the default, it is still possible to tweak the error message(s). This is assuming that you&#8217;ve set up <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/pro-additional-fields\/\">Additional Fields with Events Calendar Pro<\/a>. For this example, these are the Additional Fields we will be requiring and altering the error message: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"641\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.20.31@2x-1024x641.png\" alt=\"\" class=\"wp-image-1963613\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.20.31@2x-1024x641.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.20.31@2x-300x188.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.20.31@2x-768x481.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.20.31@2x-1536x962.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.20.31@2x-2048x1282.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Here are the <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form\/#additional-fields\">snippets<\/a> all together to require and label all our additional fields at once (keeping in mind that in the example these are the custom fields 2, 3, and 5, which might be different on your site):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nfunction my_community_required_fields( $fields ) {\n\tif ( ! is_array( $fields ) ) {\n\t\treturn $fields;\n\t}\n\t$fields&#x5B;] = &#039;_ecp_custom_2&#039;; \n\t$fields&#x5B;] = &#039;_ecp_custom_3&#039;; \n\t$fields&#x5B;] = &#039;_ecp_custom_5&#039;;\n\treturn $fields;\n}\n\nadd_filter( &#039;tec_events_community_allowed_fields&#039;, &#039;my_community_allowed_fields&#039; );\n\nfunction my_community_allowed_fields( $fields ) {\n\tif ( ! is_array( $fields ) ) {\n\t\treturn $fields;\n\t}\n\t$fields&#x5B;] = &#039;_ecp_custom_2&#039;; \n\t$fields&#x5B;] = &#039;_ecp_custom_3&#039;; \n\t$fields&#x5B;] = &#039;_ecp_custom_5&#039;;\n\treturn $fields;\n}\n\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\t\/\/ Add required label if it is one of the Additional Fields.\n\tif ( strstr( $field, &#039;_ecp_custom_2&#039;) ) {\n\t\treturn $text . &#039; &lt;span class=&quot;req&quot;&gt;(required)&lt;\/span&gt;&#039;;\n\t}\n\tif ( strstr( $field, &#039;_ecp_custom_3&#039;) ) {\n\t\treturn $text . &#039; &lt;span class=&quot;req&quot;&gt;(required)&lt;\/span&gt;&#039;;\n\t}\n\tif ( strstr( $field, &#039;_ecp_custom_5&#039;) ) {\n\t\treturn $text . &#039; &lt;span class=&quot;req&quot;&gt;(required)&lt;\/span&gt;&#039;;\n\t}\n\n    \/\/ If it&#039;s not one of the Additional Fields we require, just return the label\n    return $text;\n}\n<\/pre><\/div>\n\n\n<p>Without adding our snippet to change the error messages, this is what will now show when these required fields are empty and someone tries to submit the event: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"393\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.30.47@2x-1024x393.png\" alt=\"\" class=\"wp-image-1963615\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.30.47@2x-1024x393.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.30.47@2x-300x115.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.30.47@2x-768x295.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.30.47@2x-1536x590.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.30.47@2x-2048x787.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To enhance the clarity of your error messages by pinpointing the required fields, you can integrate the following code snippet into your site:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/masoodahmed\/b61d2f36f36a03ae12b4af3597417039.js\"><\/script>\n\n\n\n<p>With the snippet added, the error message will change from &#8220;Ecp custom 2 is required&#8221; to &#8220;Additional Field is required,&#8221; as the snippet replaces the field key (_ecp_custom_2) with the field label.<\/p>\n\n\n\n<p>Another approach is to customize the error message completely; however, this works only for fields that don&#8217;t require a page reload. This is the snippet that we can add to adjust those error messages:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_action(\n\t&#039;wp_enqueue_scripts&#039;,\n\tfunction ( ) {\n\t\t\/\/ Ensure the script is enqueued.\n\t\twp_enqueue_script( &#039;tribe_events-community&#039; );\n\n\t\t\/\/ Modify the localization data.\n\t\twp_add_inline_script(\n\t\t\t&#039;tribe_events-community&#039;,\n\t\t\t&#039;if ( tribe_submit_form_i18n.errors&#x5B; &quot;_ecp_custom_2&quot; ] ) { \n        tribe_submit_form_i18n.errors&#x5B; &quot;_ecp_custom_2&quot; ] = &quot;This is a custom field... Do not skip it!&quot;; \n        }\n        if (tribe_submit_form_i18n.errors&#x5B; &quot;_ecp_custom_3&quot; ] ) { \n        tribe_submit_form_i18n.errors&#x5B; &quot;_ecp_custom_3&quot; ] = &quot;Seriously?! You\\&#039;re skipping this one too?&quot;; \n        }\n        if (tribe_submit_form_i18n.errors&#x5B; &quot;_ecp_custom_5&quot; ] ) { \n        tribe_submit_form_i18n.errors&#x5B; &quot;_ecp_custom_5&quot; ] = &quot;I\\&#039;m calling your manager.&quot;; \n        }&#039;,\n\t\t\t&#039;before&#039;\n\t\t);\n\t}\n);\n<\/pre><\/div>\n\n\n<p>And here is how that snippet will change those error messages: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"348\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.33.33@2x-1024x348.png\" alt=\"\" class=\"wp-image-1963616\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.33.33@2x-1024x348.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.33.33@2x-300x102.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.33.33@2x-768x261.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.33.33@2x-1536x522.png 1536w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/12\/CleanShot-2024-12-03-at-17.33.33@2x-2048x696.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You should tweak that snippet to match the additional field you want to change and adjust the error message(s) to be how you want them to show on your site. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-wrapping-up\">Wrapping Up<\/h2>\n\n\n\n<p>If you run into any issues, feel free to open a ticket with our support team. We\u2019re always here to help with the basics, but please keep in mind that our ability to assist with customizations might be a bit limited. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, the only fields required when submitting an event through the Community plugin are &#8216;Title&#8217; and &#8216;Description&#8217;, though you can also set other fields as required with this guide. If you would like to customize the error messages displayed to a user when a required field is missing, this is possible through the process&#8230;<\/p>\n","protected":false},"author":44,"featured_media":1955565,"comment_status":"open","ping_status":"open","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":[1],"tags":[],"stellar-product-taxonomy":[],"class_list":["post-1963464","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"acf":[],"taxonomy_info":{"category":[{"value":1,"label":"Uncategorized"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Sam Dokus","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/sam-dokus\/"},"comment_info":0,"category_info":[{"term_id":1,"name":"Uncategorized","slug":"uncategorized","term_group":0,"term_taxonomy_id":1,"taxonomy":"category","description":"","parent":0,"count":139,"filter":"raw","term_order":"0","cat_ID":1,"category_count":139,"category_description":"","cat_name":"Uncategorized","category_nicename":"uncategorized","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1963464","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\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1963464"}],"version-history":[{"count":7,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1963464\/revisions"}],"predecessor-version":[{"id":1966094,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1963464\/revisions\/1966094"}],"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=1963464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1963464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1963464"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1963464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}