{"id":16098,"date":"2025-11-04T21:23:46","date_gmt":"2025-11-04T21:23:46","guid":{"rendered":"https:\/\/www.kadencewp.com\/help-center\/?post_type=docs&#038;p=16098"},"modified":"2026-04-22T16:24:03","modified_gmt":"2026-04-22T16:24:03","password":"","slug":"form-adv-block-disallowed-comment-keys","status":"publish","type":"docs","link":"https:\/\/www.kadencewp.com\/help-center\/docs\/kadence-blocks\/form-adv-block-disallowed-comment-keys\/","title":{"rendered":"How to Block Form (Adv) Spam Using WordPress Disallowed Comment Keys"},"content":{"rendered":"\n<p>Spam form submissions can be a frustrating problem for websites owners. Fortunately, WordPress provides a built-in feature called <strong>Disallowed Comment Keys<\/strong>, which allows you to specify words and\/or phrases that should be blocked from comments and form submissions. By leveraging this feature with a small custom code snippet, you can automatically reject form entries that contain these unwanted terms, helping to keep your inbox free from spam. This guide walks you through how to integrate Disallowed Comment Keys with Kadence Advanced Forms to help prevent spam submissions.<\/p>\n\n\n<style>.kb-table-of-content-nav.kb-table-of-content-id16098_df4aed-ce .kb-table-of-content-wrap{padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);}.kb-table-of-content-nav.kb-table-of-content-id16098_df4aed-ce .kb-table-of-contents-title-wrap{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id16098_df4aed-ce .kb-table-of-contents-title{font-weight:regular;font-style:normal;}.kb-table-of-content-nav.kb-table-of-content-id16098_df4aed-ce .kb-table-of-content-wrap .kb-table-of-content-list{font-weight:regular;font-style:normal;margin-top:var(--global-kb-spacing-sm, 1.5rem);margin-right:0px;margin-bottom:0px;margin-left:0px;}<\/style>\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading16098_05bc85-ca, .wp-block-kadence-advancedheading.kt-adv-heading16098_05bc85-ca[data-kb-block=\"kb-adv-heading16098_05bc85-ca\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading16098_05bc85-ca mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading16098_05bc85-ca[data-kb-block=\"kb-adv-heading16098_05bc85-ca\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading16098_05bc85-ca img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading16098_05bc85-ca[data-kb-block=\"kb-adv-heading16098_05bc85-ca\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading16098_05bc85-ca wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading16098_05bc85-ca\">The Code Snippet<\/h2>\n\n\n\n<p>Add the following PHP code snippet to your site.  This can be added using a <a href=\"https:\/\/www.kadencewp.com\/help-center\/docs\/kadence-theme\/how-to-add-a-custom-filter-or-function-with-code-snippets\/\" data-type=\"docs\" data-id=\"1077\">code snippets plugin<\/a> or, if you&#8217;re using a child theme, to your functions.php file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Reject Kadence Advanced Form submissions based on Disallowed Comment Keys\n *\/\nadd_filter( 'kadence_blocks_advanced_form_submission_reject', function( $reject, $form_args, $processed_fields, $post_id ) {\n    \/\/ Get the disallowed keys from WordPress settings\n    $disallowed = trim( get_option( 'disallowed_keys' ) );\n    if ( empty( $disallowed ) ) {\n        return $reject;\n    }\n    $disallowed_keys = array_filter( array_map( 'trim', explode( \"\\n\", $disallowed ) ) );\n\n    \/\/ Combine all 'value' fields\n    $submitted_content = '';\n    foreach ( $processed_fields as $field ) {\n        if ( isset( $field['value'] ) ) {\n            if ( is_array( $field['value'] ) ) {\n                $submitted_content .= ' ' . implode( ' ', $field['value'] );\n            } else {\n                $submitted_content .= ' ' . $field['value'];\n            }\n        }\n    }\n    $submitted_content = strtolower( $submitted_content );\n\n    \/\/ Check against disallowed keys\n    foreach ( $disallowed_keys as $word ) {\n        $word = strtolower( trim( $word ) );\n        if ( $word &amp;&amp; preg_match( '\/\\b' . preg_quote( $word, '\/' ) . '\\b\/i', $submitted_content ) ) {\n            return true;\n        }\n    }\n    return $reject;\n}, 10, 4 );<\/code><\/pre>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading16098_e7843b-0b, .wp-block-kadence-advancedheading.kt-adv-heading16098_e7843b-0b[data-kb-block=\"kb-adv-heading16098_e7843b-0b\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading16098_e7843b-0b mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading16098_e7843b-0b[data-kb-block=\"kb-adv-heading16098_e7843b-0b\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading16098_e7843b-0b img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading16098_e7843b-0b[data-kb-block=\"kb-adv-heading16098_e7843b-0b\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading16098_e7843b-0b wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading16098_e7843b-0b\">Update Disallowed Comment Keys<\/h2>\n\n\n\n<p>Before your custom filter can block spam in Kadence Advanced Forms, you need to define which words or phrases should be disallowed. WordPress makes this easy with the <strong>Disallowed Comment Keys<\/strong> list. By populating this list, you tell your site which terms should automatically trigger a rejection when found in form submissions. Follow the steps below to set up your disallowed words.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to your WordPress dashboard and navigate to: Settings \u2192 Discussion<\/li>\n\n\n\n<li>Scroll down to the &#8220;Comment Moderation \/ Disallowed Comment Keys&#8221; section.<\/li>\n\n\n\n<li>In the Disallowed Comment Keys textarea, enter the words or phrases you want to block.\n<ul class=\"wp-block-list\">\n<li>Place each word or phrase on its own line.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Click Save Changes at the bottom of the page.<\/li>\n<\/ol>\n\n\n<style>.kb-image16098_2f9fc3-c1 .kb-image-has-overlay:after{opacity:0.3;}<\/style>\n<figure class=\"wp-block-kadence-image kb-image16098_2f9fc3-c1 size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2304\" height=\"556\" src=\"https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM.png\" alt=\"WordPress Disallowed Comment Keys\" class=\"kb-img wp-image-16111\" srcset=\"https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM.png 2304w, https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM-300x72.png 300w, https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM-1024x247.png 1024w, https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM-768x185.png 768w, https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM-1536x371.png 1536w, https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM-2048x494.png 2048w, https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/11\/Screenshot-2025-11-04-at-3.15.18-PM-360x87.png 360w\" sizes=\"auto, (max-width: 2304px) 100vw, 2304px\" \/><\/figure>\n\n\n\n<p>Once configured, these words and phrases will be checked against form submissions using the custom Kadence filter, helping you automatically block spam.<\/p>\n\n\n\n<p class=\"has-theme-palette-8-background-color has-background\">NOTE:  The above code snippet is designed to avoid partial matches.  For example, adding the word &#8220;spam&#8221; to the list will not block the word &#8220;spammer&#8221;<\/p>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading16098_c5b9b1-cf, .wp-block-kadence-advancedheading.kt-adv-heading16098_c5b9b1-cf[data-kb-block=\"kb-adv-heading16098_c5b9b1-cf\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading16098_c5b9b1-cf mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading16098_c5b9b1-cf[data-kb-block=\"kb-adv-heading16098_c5b9b1-cf\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading16098_c5b9b1-cf img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading16098_c5b9b1-cf[data-kb-block=\"kb-adv-heading16098_c5b9b1-cf\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading16098_c5b9b1-cf wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading16098_c5b9b1-cf\">Conclusion<\/h2>\n\n\n\n<p>By combining WordPress Disallowed Comment Keys with a custom Kadence Advanced Form filter, you can effectively block spam submissions before they reach your inbox. Any submission containing a disallowed word or phrase will be automatically rejected, and importantly, rejected submissions are not saved in your database and are not sent via email.<\/p>\n\n\n\n<p>Regularly updating your Disallowed Comment Keys list and using whole-word matching helps keep your forms protected while avoiding accidental blocking of legitimate submissions. With this approach, you can maintain clean, spam-free form entries and focus on the messages that truly matter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spam form submissions can be a frustrating problem for websites owners. Fortunately, WordPress provides a built-in feature called Disallowed Comment Keys, which allows you to specify words and\/or phrases that should be blocked from comments and form submissions. By leveraging this feature with a small custom code snippet, you can automatically reject form entries that&#8230;<\/p>\n","protected":false},"author":227588,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":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,"_kad_post_classname":"","footnotes":""},"doc_category":[420],"doc_tag":[],"knowledge_base":[7],"class_list":["post-16098","docs","type-docs","status-publish","hentry","doc_category-blocks-advanced","knowledge_base-kadence-blocks"],"year_month":"2026-04","word_count":513,"total_views":"1070","reactions":{"happy":"1","normal":"0","sad":"1"},"author_info":{"display_name":"Anthony Paparelli","author_link":"https:\/\/www.kadencewp.com\/help-center\/author\/anthony-paparelli\/"},"doc_category_info":[{"term_name":"Advanced","term_url":"https:\/\/www.kadencewp.com\/help-center\/knowledge-base\/kadence-blocks\/blocks-advanced\/"}],"doc_tag_info":[],"knowledge_base_info":[{"term_name":"Kadence Blocks","term_url":"https:\/\/www.kadencewp.com\/help-center\/knowledge-base\/kadence-blocks\/","term_slug":"kadence-blocks"}],"knowledge_base_slug":["kadence-blocks"],"taxonomy_info":{"doc_category":[{"value":420,"label":"Advanced"}],"knowledge_base":[{"value":7,"label":"Kadence Blocks"}]},"featured_image_src_large":false,"comment_info":0,"_links":{"self":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/16098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/users\/227588"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/comments?post=16098"}],"version-history":[{"count":3,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/16098\/revisions"}],"predecessor-version":[{"id":16114,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/16098\/revisions\/16114"}],"wp:attachment":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/media?parent=16098"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/doc_category?post=16098"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/doc_tag?post=16098"},{"taxonomy":"knowledge_base","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/knowledge_base?post=16098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}