{"id":6489,"date":"2014-05-20T16:58:48","date_gmt":"2014-05-20T20:58:48","guid":{"rendered":"http:\/\/localhost\/documentation\/"},"modified":"2023-08-23T10:15:03","modified_gmt":"2023-08-23T14:15:03","slug":"gform_allowable_tags","status":"publish","type":"post","link":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/","title":{"rendered":"gform_allowable_tags"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-introduction\">Introduction<\/h2>\n\n\n\n<p>During form submission when the field values are being saved the values are sanitized to prevent potentially dangerous content such as scripts from being saved to the database.<\/p>\n\n\n\n<p>The gform_allowable_tags filter can be used to control the usage of the PHP <a href=\"http:\/\/php.net\/manual\/en\/function.strip-tags.php\">strip_tags()<\/a> and the WordPress <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_kses_post\/\">wp_kses_post()<\/a> functions when sanitizing the submitted field values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-usage\">Usage<\/h2>\n\n\n\n<p>The base filter which would run for all forms and fields can be used like so:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; title: ; notranslate\" title=\"\">\nadd_filter( 'gform_allowable_tags', 'your_function_name', 10, 3 );\n<\/pre><\/div>\n\n\n<p>You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; title: ; notranslate\" title=\"\">\nadd_filter( 'gform_allowable_tags_6', 'your_function_name', 10, 3 );\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-parameters\">Parameters<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$allowable_tags<\/strong>\u00a0<a href=\"https:\/\/docs.gravityforms.com\/string\">string<\/a>\u00a0|\u00a0<a href=\"https:\/\/docs.gravityforms.com\/boolean\">boolean<\/a><br>Default value is always\u00a0<strong>false<\/strong>. See examples below for details.<\/li>\n\n\n\n<li><strong>$field<\/strong>\u00a0<a href=\"https:\/\/docs.gravityforms.com\/field-object\">Field Object<\/a><br>The field currently being processed.<\/li>\n\n\n\n<li><strong>$form_id<\/strong>\u00a0<a href=\"https:\/\/docs.gravityforms.com\/integer\">integer<\/a><br>The ID of the current form.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-examples\">Examples<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-return-a-string-containing-html-tags\">1. Return a string containing HTML tags<\/h3>\n\n\n\n<p>When you return a string containing specific HTML tags the field value will first be passed through the WordPress <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_kses_post\/\">wp_kses_post()<\/a> function which will sanitize the value leaving only the HTML tags WordPress permits in post content. The value will then be passsed through the PHP <a href=\"http:\/\/php.net\/manual\/en\/function.strip-tags.php\">strip_tags()<\/a> function which will remove all remaining tags execpt those you have specified.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; title: ; notranslate\" title=\"\">\nadd_filter( &#039;gform_allowable_tags_6&#039;, &#039;allow_basic_tags&#039; );\nfunction allow_basic_tags( $allowable_tags ) {\n    return &#039;&lt;p&gt;&lt;a&gt;&lt;strong&gt;&lt;em&gt;&#039;;\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-return-true\">2. Return true<\/h3>\n\n\n\n<p>When you return true the field value will be passed through the WordPress <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_kses_post\/\">wp_kses_post()<\/a> function which will sanitize the value leaving only the HTML tags WordPress permits in post content.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; title: ; notranslate\" title=\"\">\nadd_filter( 'gform_allowable_tags_6', '__return_true' );\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-return-false\">3. Return false<\/h3>\n\n\n\n<p>When you return false the field value will be saved without being sanitized. Please note, the value may still be sanitized before it is displayed in the admin or when merge tags are processed to prevent potentially dangerous scripts from running.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; title: ; notranslate\" title=\"\">\nadd_filter( 'gform_allowable_tags_6', '__return_false' );\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-placement\">Placement<\/h2>\n\n\n\n<p>This code should be placed in the <a href=\"http:\/\/codex.wordpress.org\/Theme_Development#Functions_File\">functions.php file<\/a> of your active theme.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-source-code\">Source Code<\/h2>\n\n\n\n<p>This filter is located in GF_Field::get_allowable_tags() in <em>includes\/fields\/class-gf-field.php<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use this filter to enable HTML or specify accepted HTML tags in submitted entry data.<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_autodraft_ids":null,"_sb_is_suggestion_mode":false,"_sb_show_suggestion_boards":false,"_sb_show_comment_boards":false,"_sb_suggestion_history":"","_sb_update_block_changes":"","_is_real_time_mode":false,"_realtime_collaborators":"","footnotes":"","jetpack_post_was_ever_published":false,"cf_checklist_status":[]},"categories":[228],"tags":[],"class_list":["post-6489","post","type-post","status-publish","format-standard","hentry","category-validation","wpautop"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>gform_allowable_tags - Gravity Forms Documentation<\/title>\n<meta name=\"description\" content=\"gform_allowable_tags: Define allowable HTML tags in Gravity Forms for secure data submission and display. Learn more today!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"gform_allowable_tags\" \/>\n<meta property=\"og:description\" content=\"gform_allowable_tags: Define allowable HTML tags in Gravity Forms for secure data submission and display. Learn more today!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/\" \/>\n<meta property=\"og:site_name\" content=\"Gravity Forms Documentation\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-20T20:58:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-23T14:15:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2023\/08\/gf-docs-default-v3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"544\" \/>\n\t<meta property=\"og:image:height\" content=\"288\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Justin Pakes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@gravityforms\" \/>\n<meta name=\"twitter:site\" content=\"@gravityforms\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Justin Pakes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/\"},\"author\":{\"name\":\"Justin Pakes\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/person\\\/8a88745ec2ee5bc1bb24eea8634bf376\"},\"headline\":\"gform_allowable_tags\",\"datePublished\":\"2014-05-20T20:58:48+00:00\",\"dateModified\":\"2023-08-23T14:15:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/\"},\"wordCount\":314,\"publisher\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#organization\"},\"articleSection\":[\"Validation Filters\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/\",\"name\":\"gform_allowable_tags - Gravity Forms Documentation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#website\"},\"datePublished\":\"2014-05-20T20:58:48+00:00\",\"dateModified\":\"2023-08-23T14:15:03+00:00\",\"description\":\"gform_allowable_tags: Define allowable HTML tags in Gravity Forms for secure data submission and display. Learn more today!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gform_allowable_tags\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/docs.gravityforms.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"gform_allowable_tags\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#website\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/\",\"name\":\"Gravity Forms Documentation\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/docs.gravityforms.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#organization\",\"name\":\"Gravity Forms\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/gravity-forms-2020-logo-stacked.png\",\"contentUrl\":\"https:\\\/\\\/docs.gravityforms.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/gravity-forms-2020-logo-stacked.png\",\"width\":392,\"height\":515,\"caption\":\"Gravity Forms\"},\"image\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/gravityforms\",\"http:\\\/\\\/@gravityforms.com\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/person\\\/8a88745ec2ee5bc1bb24eea8634bf376\",\"name\":\"Justin Pakes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g\",\"caption\":\"Justin Pakes\"},\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/author\\\/pakes\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"gform_allowable_tags - Gravity Forms Documentation","description":"gform_allowable_tags: Define allowable HTML tags in Gravity Forms for secure data submission and display. Learn more today!","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:\/\/docs.gravityforms.com\/gform_allowable_tags\/","og_locale":"en_US","og_type":"article","og_title":"gform_allowable_tags","og_description":"gform_allowable_tags: Define allowable HTML tags in Gravity Forms for secure data submission and display. Learn more today!","og_url":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/","og_site_name":"Gravity Forms Documentation","article_published_time":"2014-05-20T20:58:48+00:00","article_modified_time":"2023-08-23T14:15:03+00:00","og_image":[{"width":544,"height":288,"url":"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2023\/08\/gf-docs-default-v3.png","type":"image\/png"}],"author":"Justin Pakes","twitter_card":"summary_large_image","twitter_creator":"@gravityforms","twitter_site":"@gravityforms","twitter_misc":{"Written by":"Justin Pakes","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/#article","isPartOf":{"@id":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/"},"author":{"name":"Justin Pakes","@id":"https:\/\/docs.gravityforms.com\/#\/schema\/person\/8a88745ec2ee5bc1bb24eea8634bf376"},"headline":"gform_allowable_tags","datePublished":"2014-05-20T20:58:48+00:00","dateModified":"2023-08-23T14:15:03+00:00","mainEntityOfPage":{"@id":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/"},"wordCount":314,"publisher":{"@id":"https:\/\/docs.gravityforms.com\/#organization"},"articleSection":["Validation Filters"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/","url":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/","name":"gform_allowable_tags - Gravity Forms Documentation","isPartOf":{"@id":"https:\/\/docs.gravityforms.com\/#website"},"datePublished":"2014-05-20T20:58:48+00:00","dateModified":"2023-08-23T14:15:03+00:00","description":"gform_allowable_tags: Define allowable HTML tags in Gravity Forms for secure data submission and display. Learn more today!","breadcrumb":{"@id":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/docs.gravityforms.com\/gform_allowable_tags\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/docs.gravityforms.com\/gform_allowable_tags\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/docs.gravityforms.com\/"},{"@type":"ListItem","position":2,"name":"gform_allowable_tags"}]},{"@type":"WebSite","@id":"https:\/\/docs.gravityforms.com\/#website","url":"https:\/\/docs.gravityforms.com\/","name":"Gravity Forms Documentation","description":"","publisher":{"@id":"https:\/\/docs.gravityforms.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/docs.gravityforms.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/docs.gravityforms.com\/#organization","name":"Gravity Forms","url":"https:\/\/docs.gravityforms.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/docs.gravityforms.com\/#\/schema\/logo\/image\/","url":"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2020\/01\/gravity-forms-2020-logo-stacked.png","contentUrl":"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2020\/01\/gravity-forms-2020-logo-stacked.png","width":392,"height":515,"caption":"Gravity Forms"},"image":{"@id":"https:\/\/docs.gravityforms.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/gravityforms","http:\/\/@gravityforms.com"]},{"@type":"Person","@id":"https:\/\/docs.gravityforms.com\/#\/schema\/person\/8a88745ec2ee5bc1bb24eea8634bf376","name":"Justin Pakes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g","caption":"Justin Pakes"},"url":"https:\/\/docs.gravityforms.com\/author\/pakes\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pdGaEa-1GF","_links":{"self":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts\/6489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/comments?post=6489"}],"version-history":[{"count":3,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts\/6489\/revisions"}],"predecessor-version":[{"id":37131,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts\/6489\/revisions\/37131"}],"wp:attachment":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/media?parent=6489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/categories?post=6489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/tags?post=6489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}