{"id":640,"date":"2019-11-22T22:22:45","date_gmt":"2019-11-22T15:22:45","guid":{"rendered":"https:\/\/lab.wptips.dev\/?p=640"},"modified":"2020-06-21T09:49:54","modified_gmt":"2020-06-21T02:49:54","slug":"contact-form-7","status":"publish","type":"post","link":"https:\/\/pixelstudio.id\/blog\/contact-form-7\/","title":{"rendered":"Contact Form 7 &#8211; The King of Contact Plugin"},"content":{"rendered":"\n<p>Contact Form 7 (also known as <strong>CF7<\/strong>) is one of the oldest plugin in the market. Just like the name suggests, it is used to create a contact form.<\/p>\n\n\n\n<p>In this article we will discuss why this plugin is still the king of Contact Form.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Dead Simple<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"568\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2019\/11\/cf7-form-builder.jpg\" alt=\"\" class=\"wp-image-810\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2019\/11\/cf7-form-builder.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2019\/11\/cf7-form-builder-480x364.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>The infamous basic form builder of CF7<\/figcaption><\/figure><\/div>\n\n\n\n<p>By far the most lightweight and fastest contact plugin. The builder pictured above is basically just <code>textarea<\/code> but it does allow more flexibility such as adding HTML wrapper.<\/p>\n\n\n\n<p>It&#8217;s feature is also just enough to <strong>cover most use cases<\/strong>. One missing important one is a way to save submission which can be done with <a rel=\"noreferrer noopener\" aria-label=\"Flamingo (opens in a new tab)\" href=\"https:\/\/wordpress.org\/plugins\/flamingo\/\" target=\"_blank\">Flamingo<\/a>, a plugin made by the same developer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.  Developer Friendly<\/h2>\n\n\n\n<p>You can hook to almost any part of CF7. You can add complex validation, create dynamic default value, do something before\/after submission, etc.<\/p>\n\n\n\n<p>Let&#8217;s say we want visitor to be able to create a new post. We created a CF7 form with Title and Content field. Then we add the snippet below which will run after submission:<\/p>\n\n\n\n<pre title=\"functions.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter( 'wpcf7_before_send_mail', 'create_post_after_submission');\n\nfunction create_post_after_submission( $form ) {\n  $sub = WPCF7_Submission::get_instance();\n  $data = $sub->get_posted_data();\n\n  \/\/ Check if correct form. You can get the FORM ID from the shortcode.\n  if( $data['_wpcf7'] == 1523 ) {\n    $post_data = [\n      'post_title' => $data['title'],\n      'post_content' => $data['content'],\n      'post_type' => 'post',\n      'post_status' => 'publish',\n    ];\n\n    wp_insert_post( $post_data );\n  }\n}<\/code><\/pre>\n\n\n\n<p>For more hooks, check out <a rel=\"noreferrer noopener\" aria-label=\"CF7 documentation (opens in a new tab)\" href=\"https:\/\/contactform7.com\/docs\/\" target=\"_blank\">CF7 documentation<\/a>.<\/p>\n\n\n\n<p>One other thing that is often under-appreciated is how <strong>CF7 not creating new table <\/strong>in database. That is not the case with other popular contact plugins.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Totally Free<\/h2>\n\n\n\n<p>No paid add-on, no advertisement, and no annoying donate button. Just perfect. Despite being free, the developer is active in fixing bugs and adding new features.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Reliable<\/h2>\n\n\n\n<p>I have been using CF7 for almost 6 years and I never encounter any bug. It&#8217;s one of the few plugins that I always feel safe to keep up-to-date.<\/p>\n\n\n\n<h2 class=\"has-red-color has-text-color wp-block-heading\">The Cons<\/h2>\n\n\n\n<ul><li><strong>Slight learning curve<\/strong> &#8211; But after you&#8217;re get used to it, you will find CF7 faster to setup.<\/li><li><strong>Prone to mistake<\/strong> &#8211; You need to manually check if everything is in order, including the email. If your client needs to constantly change the form, avoid using CF7.<\/li><li><strong>Lacks 3rd party integration<\/strong> &#8211; If you need the form to connect a 3rd party service, try googling it.  If not listed in Page 1, you need to create custom integration (use the same filter as snippet above).<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Contact Form 7 is a simple contact form plugin that should work for majority of websites. It is lightweight, developer friendly, FREE, and reliable.<\/p>\n\n\n\n<p>So far, the only time I don&#8217;t use CF7 is when a client needs to constantly create new form. In that case, it&#8217;s safer to use more advanced plugin like NinjaForm or GravityForm.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contact Form 7 (also known as CF7) is one of the oldest plugin in the market. Just like the name suggests, it is used to create a contact form.<\/p>\n","protected":false},"author":1,"featured_media":809,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[39],"class_list":["post-640","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugin","tag-contact-form"],"blocksy_meta":{"page_structure_type":"default","page_enable_vertical_spacing":"yes","has_hero_section":"default","hero_section":"type-1","hero_alignment1":"left","hero_alignment2":"center","hero_height":"230px","page_title_bg_type":"color","744f1b7605aaeab589d76b32462a0abc":"","custom_hero_background":{"attachment_id":null},"parallax":{"desktop":false,"tablet":false,"mobile":false},"single_meta_elements":{"author":true,"date":true,"categories":true,"comments":true,"updated":false,"tags":false},"has_meta_label":"yes","single_meta_date_format":"M j, Y","page_excerpt_visibility":{"desktop":true,"tablet":true,"mobile":false},"pageTitleFont":{"family":"Default","variation":"n7","size":{"desktop":"32px","tablet":"30px","mobile":"25px"},"line-height":"1.3","letter-spacing":"0em","text-transform":"none","text-decoration":"none"},"pageTitleFontColor":{"default":{"color":"var(--paletteColor4)"}},"pageMetaFont":{"family":"Default","variation":"n6","size":{"desktop":"12px","tablet":"12px","mobile":"12px"},"line-height":"1.3","letter-spacing":"0em","text-transform":"uppercase","text-decoration":"none"},"pageMetaFontColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"hover":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageExcerptFont":{"family":"Default","variation":"n5","size":"17px","line-height":"1.65","letter-spacing":"0em","text-transform":"none","text-decoration":"none"},"pageExcerptColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageTitleOverlay":{"default":{"color":"rgba(41, 51, 60, 0.2)"}},"pageTitleBackground":{"default":{"color":"#EDEFF2"}},"f3f8f3363cdba23d2eed875a0bb57f80":"","0fa84abeb39c8ba825298f3a00869258":"","18128ab1078c926af00faea892480150":"","5cf66d227357c3002bdb660f5ee071ea":"","36f0e779ca613a6499c2c55b602516a1":"","b77584c7b79e0efa28c050469dd217e5":"","95fcb3cd2d3da0bec156de1c9b154bad":"","1de75ead5bddf28b70f79bdbea279235":"","date_format_source":"custom","d415bd6b7d7286ea57673b65754b9d71":"","e13a36a782adaa05c9f17c104ba96885":"","dfec341b5611f466b482f5bf35801bfc":"","7a3c1cddaea9febd968d79deb9dad4df":"","df6cff5be5295b38e8724efae61e1dbf":"","8f72654a64eec2c5993f8e222d3c9674":"","0972ec3966109ec93f56c18c4a85b7c1":""},"_links":{"self":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/comments?post=640"}],"version-history":[{"count":10,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/640\/revisions"}],"predecessor-version":[{"id":1587,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/640\/revisions\/1587"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media\/809"}],"wp:attachment":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media?parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/categories?post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/tags?post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}