{"id":946,"date":"2025-03-24T14:28:06","date_gmt":"2025-03-24T14:28:06","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/allow-reviews-with-no-comment\/"},"modified":"2025-09-04T08:29:38","modified_gmt":"2025-09-04T07:29:38","slug":"allow-reviews-with-no-comment","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/allow-reviews-with-no-comment\/","title":{"rendered":"Allow reviews with no comment"},"content":{"rendered":"\n<p>The below code snippet will allow users to add reviews without entering a comment.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">function gd_snippet_allow_empty_comment( $allow, $commentdata = array() ) {\n\tif ( empty( $commentdata&#091;&#039;comment_parent&#039;&#093; ) &amp;&amp; ! empty( $commentdata&#091;&#039;comment_post_ID&#039;&#093; ) &amp;&amp; function_exists( &#039;geodir_is_gd_post_type&#039; ) &amp;&amp; geodir_is_gd_post_type( get_post_type( (int) $commentdata&#091;&#039;comment_post_ID&#039;&#093; ) ) ) {\n\t\t$allow = true;\n\t}\n\n\treturn $allow;\n}\nadd_filter( &#039;allow_empty_comment&#039;, &#039;gd_snippet_allow_empty_comment&#039;, 11, 2 );\n\nfunction gd_snippet_allow_empty_review( $allow ) {\n\t$allow = true;\n\n\treturn $allow;\n}\nadd_filter( &#039;geodir_allow_empty_review&#039;, &#039;gd_snippet_allow_empty_review&#039;, 11, 1 );\n\nfunction gd_snippet_duplicate_comment_id( $dupe_id, $commentdata ) {\n\tif ( empty( $commentdata&#091;&#039;comment_parent&#039;&#093; ) &amp;&amp; ! empty( $commentdata&#091;&#039;comment_post_ID&#039;&#093; ) &amp;&amp; function_exists( &#039;geodir_is_gd_post_type&#039; ) &amp;&amp; geodir_is_gd_post_type( get_post_type( (int) $commentdata&#091;&#039;comment_post_ID&#039;&#093; ) ) ) {\n\t\t$dupe_id = 0;\n\t}\n\n\treturn $dupe_id;\n}\nadd_filter( &#039;duplicate_comment_id&#039;, &#039;gd_snippet_duplicate_comment_id&#039;, 11, 2 );\n\nfunction gd_snippet_comment_form_defaults( $defaults ) {\n\tif ( function_exists( &#039;geodir_is_page&#039; ) &amp;&amp; geodir_is_page( &#039;single&#039; ) &amp;&amp; ! empty( $defaults&#091;&#039;comment_field&#039;&#093; ) ) {\n\t\t$defaults&#091;&#039;comment_field&#039;&#093; = str_replace( esc_html__( &#039;Enter your review comments here (required)...&#039;, &#039;geodirectory&#039; ), esc_html__( &#039;Enter your comment here...&#039;, &#039;geodirectory&#039; ), $defaults&#091;&#039;comment_field&#039;&#093; );\n\t}\n\n\treturn $defaults;\n}\nadd_filter( &#039;comment_form_defaults&#039;, &#039;gd_snippet_comment_form_defaults&#039;, 12, 1 );\n\nfunction gd_snippet_9854ef_allow_empty_text_reviews( $field ) {\n\tif ( function_exists( &#039;geodir_is_page&#039; ) &amp;&amp; geodir_is_page( &#039;single&#039; ) ) {\n\t\treturn str_replace( &#091; &#039; required=&quot;required&quot;&#039;, &#039; checked=&quot;checked&quot;&#039; &#093;, &#039;&#039;, $field );\n\t}\n\n\treturn $field;\n}\nadd_filter( &#039;comment_form_field_comment&#039;, &#039;gd_snippet_9854ef_allow_empty_text_reviews&#039;, 999, 1 );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The below code snippet will allow users to add reviews without entering a comment.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,433],"class_list":["post-946","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=946"}],"version-history":[{"count":1,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/946\/revisions"}],"predecessor-version":[{"id":2158,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/946\/revisions\/2158"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=946"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=946"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}