{"id":1393170,"date":"2017-11-27T15:59:57","date_gmt":"2017-11-27T23:59:57","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/"},"modified":"2017-11-27T15:59:57","modified_gmt":"2017-11-27T23:59:57","slug":"submission-form-required-fields-and-error-message","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/","title":{"rendered":"Submission Form &#8211; Required Fields and Error Message"},"content":{"rendered":"<p>Hi,<\/p>\n<p>We&#8217;re finally updating to the latest version of Community Events after updating our template overrides with the new functionality and views introduced earlier this year. One area we&#8217;re having trouble with is the functions to set the required fields and error message for the Community Events Submission Form.<\/p>\n<p>Following your updated article at https:\/\/theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form\/, we have added the following to our functions.php file:<\/p>\n<pre><code>\/\/Customize Event Required Fields\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[] = &#039;EventStartDate&#039;;\n    $fields[] = &#039;EventStartHour&#039;;\n    $fields[] = &#039;EventStartMinute&#039;;\t\n    $fields[] = &#039;EventURL&#039;;\n\t$fields[] = &#039;venue&#039;;\n\t$fields[] = &#039;organizer&#039;;\n\n    return $fields;\n}\n\n\/\/Customize Venue Required Fields\nadd_filter( &#039;tribe_events_community_required_venue_fields&#039;, &#039;my_venue_community_required_fields&#039;, 10, 1 );\n\nfunction my_venue_community_required_fields( $fields ) {\n    \n    if ( ! is_array( $fields ) ) {\n        return $fields;\n    }\n\n    $fields[] = &#039;Venue&#039;;\n    $fields[] = &#039;Address&#039;;\n    $fields[] = &#039;City&#039;;\n    $fields[] = &#039;State&#039;;\n    $fields[] = &#039;Zip&#039;;\n\n    return $fields;\n}\n\n\/\/Customize Organizer Required Fields\nadd_filter( &#039;tribe_events_community_required_organizer_fields&#039;, &#039;my_organizer_community_required_fields&#039;, 10, 1 );\n\nfunction my_organizer_community_required_fields( $fields ) {\n    \n    if ( ! is_array( $fields ) ) {\n        return $fields;\n    }\n\n\t$fields[] = &#039;Organizer&#039;;\n    $fields[] = &#039;email&#039;;\n\n    return $fields;\n} <\/code><\/pre>\n<p>With this code, we&#8217;ve encountered a few issues\/bugs:<br \/>\n1. The Event Description is returned as a required field, even though it is not set as required. How can we remove this as a required field?<br \/>\n2. The Event Start Hour and Event Start Minute are not being recognized as having values submitted even though the time fields have values selected from the time drop down.<br \/>\n3. The Event Date and Event Times submitted are not retained when an error (required field message) is returned (they reset to the default values).<br \/>\n4. In addition to the specific Venue and Organizer fields being returned as &#8220;Organizer Name is required&#8221;, etc, an additional row of &#8220;Organizer is required&#8221; is also returned (see attached screenshot). Is the code at the bottom of this post still valid with the recent version of the plugins to modify the error messages? (this was crafted by Modern Tribe last year, but given the major updates to Community Events, we&#8217;re unsure if using this would lead to issues).<\/p>\n<p>Can you please advise how we can get these fixed\/resolved?<\/p>\n<p>Thank you!<br \/>\nKarly<\/p>\n<pre><code>\/\/ Customize Required Fields Error Message\nfunction ce_custom_error_msg( $errors ) {\n\/\/ Don&#039;t filter if it is an &#039;update&#039; or other type of message\nif ( $errors[0][&#039;type&#039;] != &#039;error&#039; ) return $errors;\n\n$existing_errors = &#039;&#039;;\n$type = &#039;error&#039;;\n\nif ( is_array( $errors ) ) {\n$existing_errors = $errors[0][&#039;message&#039;];\n$type = $errors[0][&#039;type&#039;];\n}\n\n\/\/ Set overall message by appending a heading to the front\nif ( strpos($_SERVER[&#039;REQUEST_URI&#039;], &#039;\/events\/community\/edit\/&#039;) !== 0 ) {\n\/\/ You are not editing an event\n$errors[0] = array(\n&#039;type&#039; =&gt; $type,\n&#039;message&#039; =&gt; &#039;&lt;strong&gt;There were errors with your submission.&lt;\/br&gt;\nPlease review the following and resubmit your event.&lt;\/br&gt;\n*If you are uploading a logo, you will need to reselect it.&lt;\/br&gt;&lt;\/br&gt;&lt;\/strong&gt;&#039; . $existing_errors\n);\n}\n\nif ( strpos($_SERVER[&#039;REQUEST_URI&#039;], &#039;\/events\/community\/edit\/&#039;) === 0 ) {\n\/\/ You are editing an event\n$errors[0] = array(\n&#039;type&#039; =&gt; $type,\n&#039;message&#039; =&gt; &#039;&#039; . $existing_errors\n);\n}\n\n\/\/ User str_replace to choose a specific message to change\n$errors[0][&#039;message&#039;] = str_replace( &#039;Event URL is required&#039;, &#039;Event Website URL is required&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;Tax Input is required&#039;, &#039;Event Category is required&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;Organizer is required&#039;, &#039;Organizer Name and Email are required&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;G-recaptcha-response is required&#039;, &#039;&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;Venue Name is required&#039;, &#039;&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;Venue is required&#039;, &#039;&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;Organizer Name is required&#039;, &#039;&#039;, $errors[0][&#039;message&#039;] );\n$errors[0][&#039;message&#039;] = str_replace( &#039;Invalid value for the Anti-Spam Check&#039;, &#039;Please confirm you are human by clicking the I\\&#039;m not a robot checkbox&#039;, $errors[0][&#039;message&#039;] );\n\nreturn $errors;\n}\n\n\/\/ Return custom error message\nadd_filter( &#039;tribe_community_events_form_errors&#039;, &#039;ce_redirect_after_submit&#039;, 10, 1 );\nfunction ce_redirect_after_submit( $messages ) {\nif ( is_array( $messages ) &amp;&amp; !empty( $messages ) ) {\n$messages = ce_custom_error_msg( $messages );\n$first_message = reset( $messages );\nif ( $first_message[&#039;type&#039;] == &#039;update&#039; ) {\nadd_action( &#039;parse_request&#039;, &#039;tribe_redirect_after_community_submission&#039;, 11, 1 );\n}\n}\nreturn $messages;\n}<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-1393170","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Submission Form - Required Fields and Error Message -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Submission Form - Required Fields and Error Message -\" \/>\n<meta property=\"og:description\" content=\"Hi, We&#8217;re finally updating to the latest version of Community Events after updating our template overrides with the new functionality and views introduced earlier this year. One area we&#8217;re having trouble with is the functions to set the required fields and error message for the Community Events Submission Form. Following your updated article at https:\/\/theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form\/, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/\",\"name\":\"Submission Form - Required Fields and Error Message -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-11-27T23:59:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Community Events\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/community-events\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Submission Form &#8211; Required Fields and Error Message\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Submission Form - Required Fields and Error Message -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/","og_locale":"en_US","og_type":"article","og_title":"Submission Form - Required Fields and Error Message -","og_description":"Hi, We&#8217;re finally updating to the latest version of Community Events after updating our template overrides with the new functionality and views introduced earlier this year. One area we&#8217;re having trouble with is the functions to set the required fields and error message for the Community Events Submission Form. Following your updated article at https:\/\/theeventscalendar.com\/knowledgebase\/required-fields-for-events-submission-form\/, [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/","name":"Submission Form - Required Fields and Error Message -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-11-27T23:59:57+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/submission-form-required-fields-and-error-message\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Community Events","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/community-events\/"},{"@type":"ListItem","position":5,"name":"Submission Form &#8211; Required Fields and Error Message"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1393170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1393170\/revisions"}],"predecessor-version":[{"id":1396631,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1393170\/revisions\/1396631"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1393170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}