{"id":217,"date":"2024-06-28T09:58:08","date_gmt":"2024-06-28T13:58:08","guid":{"rendered":"https:\/\/htmlformsplugin.com\/?p=217"},"modified":"2025-02-13T13:21:03","modified_gmt":"2025-02-13T18:21:03","slug":"code-snippets","status":"publish","type":"post","link":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/","title":{"rendered":"Code Snippets"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add Class Attribute to Form Tag<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_form_element_class_attr',\n\tfunction( $class_attr ) {\n\t\treturn $class_attr . ' my-class';\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Add Custom Attribute to Form Tag<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_form_html',\n\tfunction( $html ) {\n\t\t$html = str_replace( '&lt;form ', '&lt;form ms-signup=\"true\" ', $html );\n\t\treturn $html;\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Add Custom Form Action<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">use HTML_Forms\\Actions\\Action;\nuse HTML_Forms\\Form;\nuse HTML_Forms\\Submission;\n\nclass MyCustomAction extends Action {\n\n\tpublic $type  = 'pushbullet';\n\tpublic $label = '';\n\n\tpublic function __construct() {\n\t\t$this-&gt;label = __( 'Send to Pushbullet', 'html-forms' );\n\t}\n\n\t\/**\n\t * @return array\n\t *\/\n\tprivate function get_default_settings() {\n\t\treturn array(\n\t\t\t'url' =&gt; '',\n\t\t);\n\t}\n\n\t\/**\n\t * @param array $settings\n\t * @param string|int $index\n\t *\/\n\tpublic function page_settings( $settings, $index ) {\n\t\t$settings = array_merge( $this-&gt;get_default_settings(), $settings );\n\t\t?&gt;\n\t\t&lt;span class=\"hf-action-summary\"&gt;&lt;?php printf( 'Pushbullet' ); ?&gt;&lt;\/span&gt;\n\t\t&lt;input type=\"hidden\" name=\"form[settings][actions][&lt;?php echo $index; ?&gt;][type]\" value=\"&lt;?php echo $this-&gt;type; ?&gt;\" \/&gt;\n\t\t&lt;table class=\"form-table\"&gt;\n\t\t\t&lt;tr&gt;\n\t\t\t\t&lt;th&gt;&lt;label&gt;&lt;?php echo __( 'Pushbullet API URL', 'html-forms' ); ?&gt; &lt;span class=\"hf-required\"&gt;*&lt;\/span&gt;&lt;\/label&gt;&lt;\/th&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t&lt;input name=\"form[settings][actions][&lt;?php echo $index; ?&gt;][url]\" value=\"&lt;?php echo esc_attr( $settings['url'] ); ?&gt;\" type=\"text\" class=\"regular-text\" placeholder=\"http:\/\/....\" required \/&gt;\n\t\t\t\t&lt;\/td&gt;\n\t\t\t&lt;\/tr&gt;\n\t\t&lt;\/table&gt;\n\t\t&lt;?php\n\t}\n\n\t\/**\n\t * Processes this action\n\t *\n\t * @param array $settings\n\t * @param Submission $submission\n\t * @param Form $form\n\t *\/\n\tpublic function process( array $settings, Submission $submission, Form $form ) {\n\t\t\/\/ TODO: Send HTTP request to PushBullet API URL: $settings['url']\n\t}\n}\n\n$my_custom_action = new MyCustomAction();\n$my_custom_action-&gt;hook();<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Add HTML to Form Dynamically<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_form_markup',\n\tfunction( $markup ) {\n\t\t$markup .= '&lt;input type=\"hidden\" name=\"HIDDEN_FIELD\" value=\"My value\" \/&gt;';\n\t\treturn $markup;\n\t}\n);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">HTML forms will check the number of configured fields versus the number of submitted fields, and ignore the submission if it&#8217;s mismatching. For that reason, if you like to dynamically add more than 1 field dynamically, you need to disable the field counter with the following filter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter( 'hf_validate_form_request_size', '__return_false' );<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Add Tag to Mailchimp Contact<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This requires the <a href=\"https:\/\/wordpress.org\/plugins\/mailchimp-for-wp\/\">MC4WP<\/a> plugin to be active and configured. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Give users a link to a form, and include &#8220;?hfmuc_email={{their_email}}&#8221; as a querystring parameter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then make sure the form has a hidden field named &#8220;EMAIL&#8221; whose value is &#8220;{{hfmuc_email}}&#8221; like this example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\"><code>&lt;input type=\"hidden\" name=\"EMAIL\" placeholder=\"Your email\" required value=\"{{hfmuc_email}}\" \/&gt;<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Find your <a href=\"https:\/\/mailchimp.com\/help\/find-audience-id\/\">list ID<\/a> and put it in $list_id below. Then local the HTML Forms slug (seen when editing the form) and put it in $form_slug. Next, add any tags you want to $tags_data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now the user will get a link to the form, fill it out (no need to re-enter their email), and upon successful submission, those tags will be added to their Mailchimp contact.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">use \\HTML_Forms\\Submission;\nuse HTML_Forms\\Form;\n\n\/\/ Get the user's email from the query parameters\nadd_filter(\n\t'hf_form_html',\n\tfunction ( $html ) {\n\t\t$email = isset( $_GET['hfmuc_email'] ) ? $_GET['hfmuc_email'] : '';\n\t\treturn str_replace( '{{hfmuc_email}}', $email, $html );\n\t}\n);\n\/\/ Adds tags to the given user.\nadd_action(\n\t'hf_form_success',\n\tfunction ( $submission, $form ) {\n\t\t\/\/ Check that it's the right form.\n\t\t$form_slug = 'survey-1';\n\t\tif ( $form-&gt;slug !== $form_slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\t$email_address = $submission-&gt;data['EMAIL'];\n\t\t$api           = mc4wp_get_api_v3();\n\n\t\t\/\/ aka \"audience ID\". See https:\/\/mailchimp.com\/help\/find-audience-id\/\n\t\t$list_id = '32ccd044c3';\n\n\t\t\/\/ see https:\/\/mailchimp.com\/developer\/reference\/lists\/list-members\/list-member-tags\/#read-get_lists_list_id_members_subscriber_hash_tags\n\t\t$tags_data = array(\n\t\t\t'tags' =&gt; array(\n\t\t\t\tarray(\n\t\t\t\t\t'name'   =&gt; 'Test',\n\t\t\t\t\t'status' =&gt; 'active',\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\n\t\t$result = $api-&gt;update_list_member_tags(\n\t\t\t$list_id,\n\t\t\t$email_address,\n\t\t\t$tags_data\n\t\t);\n\t},\n\t10,\n\t2\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Add URL to Email Message<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s possible to filter the email action message with PHP. This example will add the URL the form was submitted from to the end of the email notification message.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_action_email_message',\n\tfunction ( $message ) {\n\t\treturn $message . sprintf( '&lt;br \/&gt;Referrer URL: %s', esc_html( $_SERVER['REQUEST_URI'] ) );\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Form Message<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The default message keys are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>success<\/li>\n\n\n\n<li>invalid_email<\/li>\n\n\n\n<li>required_field_missing<\/li>\n\n\n\n<li>error<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_form_message_success',\n\tfunction( $message ) {\n\t\treturn 'Your custom success message here';\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Form Validation<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\/\/ validate form request (all forms)\n\/\/ this will validate that the field with name \"BEST_VEGETABLE\" is set and has a value of \"carrot\"\nadd_filter(\n\t'hf_validate_form',\n\tfunction( $error_code, $form, $data ) {\n\t\tif ( ! isset( $data['BEST_VEGETABLE'] ) || $data['BEST_VEGETABLE'] !== 'carrot' ) {\n\t\t\t$error_code = 'wrong_answer';\n\t\t}\n\n\t\treturn $error_code;\n\t},\n\t10,\n\t3\n);\n\n\/\/ validate form request (form with ID 60 only)\nadd_filter(\n\t'hf_validate_form',\n\tfunction( $error_code, $form, $data ) {\n\t\tif ( $form-&gt;ID != 60 ) {\n\t\t\treturn $error_code;\n\t\t}\n\n\t\tif ( ! isset( $data['BEST_VEGETABLE'] ) || $data['BEST_VEGETABLE'] !== 'carrot' ) {\n\t\t\t$error_code = 'wrong_answer';\n\t\t}\n\n\t\treturn $error_code;\n\t},\n\t10,\n\t3\n);\n\n\/\/ register error message for our custom error code\nadd_filter(\n\t'hf_form_message_wrong_answer',\n\tfunction( $message ) {\n\t\treturn 'Sorry, but the best vegetable is a carrot!';\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Do Not Store IP Address and User Agent<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_action(\n\t'hf_process_form',\n\tfunction( $form, $submission ) {\n\t\t$submission-&gt;ip_address = '';\n\t\t$submission-&gt;user_agent = '';\n\t},\n\t10,\n\t2\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">File Upload Direct Links<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Instruct HTML Forms to not link to WP Media attachments for uploaded files, but use a direct link to the actual file. This requires the <a href=\"https:\/\/htmlformsplugin.com\/premium\/\">HTML Forms Premium<\/a> add-on. HTML Forms Premium 1.5.0 and above include this as a setting for all <a href=\"https:\/\/htmlformsplugin.com\/kb\/file-uploads\/\">File Uploads<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter( 'hf_file_upload_use_direct_links', '__return_true' );<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Disable File Uploads to WordPress Admin Media Library<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This requires the <a href=\"https:\/\/htmlformsplugin.com\/premium\/\">HTML Forms Premium<\/a> add-on. HTML Forms Premium 1.5.0 and above include this as a setting for all <a href=\"https:\/\/htmlformsplugin.com\/kb\/file-uploads\/\">File Uploads<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter( 'hf_upload_add_to_media', '__return_false' );<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Change Maximum Size Allowed for File Uploads<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This requires the <a href=\"https:\/\/htmlformsplugin.com\/premium\/\">HTML Forms Premium<\/a> add-on. HTML Forms Premium 1.5.0 and above include this as a setting for all <a href=\"https:\/\/htmlformsplugin.com\/kb\/file-uploads\/\">File Uploads<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_upload_max_filesize',\n\tfunction( $size ) {\n\t\t\/\/ size in bytes, 1000000 = 1MB\n\t\treturn 1000000;\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Filter Email Action to Specific Email Address<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_action_email_to',\n\tfunction( $to, $submission ) {\n\t\tif ( $submission-&gt;data['FOO'] === 'BAR' ) {\n\t\t\treturn 'support@acmeinc.com';\n\t\t}\n\n\t\treturn $to; \/\/ default \"To\" as specified in action settings\n\t},\n\t10,\n\t2\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Manually Load HTML Forms JavaScript<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re having issues with the HTML Forms JavaScript file not being loaded, you can use the following snippet to load it manually.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_action(\n\t'wp_enqueue_scripts',\n\tfunction() {\n\t\twp_enqueue_script( 'html-forms' );\n\t},\n\t90\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Modify Email Action Recipient<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_action(\n\t'hf_action_email_to',\n\tfunction ( $to, \\HTML_Forms\\Submission $submission ) {\n\t\t\/\/ $to contains the default recipient, from the action settings\n\t\t\/\/ you can replace it with a different email addresses or turn it into an array of recipients\n\t\treturn array( $to, 'john.doe@email.com' );\n\t}\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Create a Multi-Step Form<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&lt;!-- Step 1 --&gt;\n&lt;div data-show-if=\"_STEP:\"&gt;\n  &lt;p&gt;\n      &lt;label&gt;Name&lt;\/label&gt;\n      &lt;input type=\"text\" name=\"NAME\" placeholder=\"\" value=\"Danny\" required \/&gt;\n  &lt;\/p&gt;\n  &lt;p&gt;\n    &lt;button type=\"button\" name=\"_STEP\" value=\"2\"&gt;Continue to step 2&lt;\/button&gt;\n  &lt;\/p&gt;\n&lt;\/div&gt;\n\n&lt;!-- Step 2 --&gt;\n&lt;div data-show-if=\"_STEP:2\"&gt;\n  &lt;p&gt;\n      &lt;label&gt;Email address&lt;\/label&gt;\n      &lt;input type=\"email\" name=\"EMAIL\" placeholder=\"Your email address\" value=\"danny@email.com\" required \/&gt;\n  &lt;\/p&gt;\n\n  &lt;p&gt;\n      &lt;button type=\"button\" name=\"_STEP\" value=\"3\"&gt;Continue to step 3&lt;\/button&gt;\n      &lt;button type=\"button\" name=\"_STEP\" value=\"\"&gt;Back&lt;\/button&gt;\n  &lt;\/p&gt;\n&lt;\/div&gt;\n\n&lt;!-- Step 3 --&gt;\n&lt;div data-show-if=\"_STEP:3\"&gt;\n  &lt;p&gt;\n      &lt;input type=\"submit\" value=\"Send\" \/&gt;\n  &lt;\/p&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Perform Action After Successful Form Submission<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This code runs for every successful form submission.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_action(\n\t'hf_form_success',\n\tfunction( $submission, $form ) {\n\t\t\/\/ You can do stuff here.\n\t\t\/\/ $form contains details about the submitted form\n\t\t\/\/ $submission contains details about the submission, like the form data.\n\t},\n\t10,\n\t2\n);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Template Tags<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This example replaces {{replace_me}} with &#8220;replaced!&#8221; using a simple string replacement.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_template_tags',\n\tfunction( $tags ) {\n\t\t$tags['replace_me'] = 'replaced!';\n\t\treturn $tags;\n\t}\n);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This example uses a function accepting a single parameter to determine the replacement value<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example: {{replace_me.foo}}<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">add_filter(\n\t'hf_template_tags',\n\tfunction( $tags ) {\n\t\t$tags['replace_me'] = function( $key ) {\n\t\t\tif ( $key === 'foo' ) {\n\t\t\t\treturn 'bar';\n\t\t\t}\n\n\t\t\treturn 'not bar';\n\t\t};\n\t\treturn $tags;\n\t}\n);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[6],"class_list":["post-217","post","type-post","status-publish","format-standard","hentry","category-kb","tag-advanced"],"yoast_head":"<title>Code Snippets - HTML Forms WordPress Plugin<\/title>\n<meta name=\"description\" content=\"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Code Snippets\" \/>\n<meta property=\"og:description\" content=\"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML Forms WordPress Plugin\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-28T13:58:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-13T18:21:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/htmlformsplugin.com\/wp-content\/uploads\/2024\/05\/open-graph-html-forms.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Brian Link\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Code Snippets\" \/>\n<meta name=\"twitter:description\" content=\"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/htmlformsplugin.com\/wp-content\/uploads\/2024\/05\/open-graph-html-forms.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brian Link\" \/>\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:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/\"},\"author\":{\"name\":\"Brian Link\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#\\\/schema\\\/person\\\/b02bbb6b44c6cb9559e0002d93d1f673\"},\"headline\":\"Code Snippets\",\"datePublished\":\"2024-06-28T13:58:08+00:00\",\"dateModified\":\"2025-02-13T18:21:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/\"},\"wordCount\":469,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#organization\"},\"keywords\":[\"Advanced\"],\"articleSection\":[\"Knowledge Base\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/\",\"url\":\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/\",\"name\":\"Code Snippets - HTML Forms WordPress Plugin\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#website\"},\"datePublished\":\"2024-06-28T13:58:08+00:00\",\"dateModified\":\"2025-02-13T18:21:03+00:00\",\"description\":\"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/kb\\\/code-snippets\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/htmlformsplugin.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Code Snippets\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#website\",\"url\":\"https:\\\/\\\/htmlformsplugin.com\\\/\",\"name\":\"HTML Forms WordPress Plugin\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/htmlformsplugin.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#organization\",\"name\":\"HTML Forms WordPress Plugin\",\"url\":\"https:\\\/\\\/htmlformsplugin.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/htmlformsplugin.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/html-forms-logo.png\",\"contentUrl\":\"https:\\\/\\\/htmlformsplugin.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/html-forms-logo.png\",\"width\":256,\"height\":256,\"caption\":\"HTML Forms WordPress Plugin\"},\"image\":{\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/htmlformsplugin.com\\\/#\\\/schema\\\/person\\\/b02bbb6b44c6cb9559e0002d93d1f673\",\"name\":\"Brian Link\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ea2350acd2040f957e4e11d136c823bc13994837d3e4a912d7d8ccd3cc6e954d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ea2350acd2040f957e4e11d136c823bc13994837d3e4a912d7d8ccd3cc6e954d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ea2350acd2040f957e4e11d136c823bc13994837d3e4a912d7d8ccd3cc6e954d?s=96&d=mm&r=g\",\"caption\":\"Brian Link\"},\"url\":\"https:\\\/\\\/htmlformsplugin.com\\\/author\\\/brian\\\/\"}]}<\/script>","yoast_head_json":{"title":"Code Snippets - HTML Forms WordPress Plugin","description":"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.","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:\/\/htmlformsplugin.com\/kb\/code-snippets\/","og_locale":"en_US","og_type":"article","og_title":"Code Snippets","og_description":"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.","og_url":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/","og_site_name":"HTML Forms WordPress Plugin","article_published_time":"2024-06-28T13:58:08+00:00","article_modified_time":"2025-02-13T18:21:03+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/htmlformsplugin.com\/wp-content\/uploads\/2024\/05\/open-graph-html-forms.png","type":"image\/png"}],"author":"Brian Link","twitter_card":"summary_large_image","twitter_title":"Code Snippets","twitter_description":"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.","twitter_image":"https:\/\/htmlformsplugin.com\/wp-content\/uploads\/2024\/05\/open-graph-html-forms.png","twitter_misc":{"Written by":"Brian Link","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/#article","isPartOf":{"@id":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/"},"author":{"name":"Brian Link","@id":"https:\/\/htmlformsplugin.com\/#\/schema\/person\/b02bbb6b44c6cb9559e0002d93d1f673"},"headline":"Code Snippets","datePublished":"2024-06-28T13:58:08+00:00","dateModified":"2025-02-13T18:21:03+00:00","mainEntityOfPage":{"@id":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/"},"wordCount":469,"commentCount":0,"publisher":{"@id":"https:\/\/htmlformsplugin.com\/#organization"},"keywords":["Advanced"],"articleSection":["Knowledge Base"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/","url":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/","name":"Code Snippets - HTML Forms WordPress Plugin","isPartOf":{"@id":"https:\/\/htmlformsplugin.com\/#website"},"datePublished":"2024-06-28T13:58:08+00:00","dateModified":"2025-02-13T18:21:03+00:00","description":"Check out our collection of simple code snippets you can use to get the most out of HTML Forms on your WordPress websites.","breadcrumb":{"@id":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/htmlformsplugin.com\/kb\/code-snippets\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/htmlformsplugin.com\/kb\/code-snippets\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/htmlformsplugin.com\/"},{"@type":"ListItem","position":2,"name":"Code Snippets"}]},{"@type":"WebSite","@id":"https:\/\/htmlformsplugin.com\/#website","url":"https:\/\/htmlformsplugin.com\/","name":"HTML Forms WordPress Plugin","description":"","publisher":{"@id":"https:\/\/htmlformsplugin.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/htmlformsplugin.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/htmlformsplugin.com\/#organization","name":"HTML Forms WordPress Plugin","url":"https:\/\/htmlformsplugin.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/htmlformsplugin.com\/#\/schema\/logo\/image\/","url":"https:\/\/htmlformsplugin.com\/wp-content\/uploads\/2024\/05\/html-forms-logo.png","contentUrl":"https:\/\/htmlformsplugin.com\/wp-content\/uploads\/2024\/05\/html-forms-logo.png","width":256,"height":256,"caption":"HTML Forms WordPress Plugin"},"image":{"@id":"https:\/\/htmlformsplugin.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/htmlformsplugin.com\/#\/schema\/person\/b02bbb6b44c6cb9559e0002d93d1f673","name":"Brian Link","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ea2350acd2040f957e4e11d136c823bc13994837d3e4a912d7d8ccd3cc6e954d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ea2350acd2040f957e4e11d136c823bc13994837d3e4a912d7d8ccd3cc6e954d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ea2350acd2040f957e4e11d136c823bc13994837d3e4a912d7d8ccd3cc6e954d?s=96&d=mm&r=g","caption":"Brian Link"},"url":"https:\/\/htmlformsplugin.com\/author\/brian\/"}]}},"_links":{"self":[{"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/posts\/217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/comments?post=217"}],"version-history":[{"count":11,"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/posts\/217\/revisions"}],"predecessor-version":[{"id":384,"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/posts\/217\/revisions\/384"}],"wp:attachment":[{"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/media?parent=217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/categories?post=217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/htmlformsplugin.com\/wp-json\/wp\/v2\/tags?post=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}