Tips for Contact Form 7

Most of sites running on WordPress don’t have complex implementation for contact forms. And almost every one of them use Contact Form 7 or  shortly CF7.

CF7’s simple implementation puts it under must use WordPress plugins category.

Following are some most common requirements developers come across and their most common solutions:

  1. Prevent spam by bots – A simple anti-spam functionality without need of any captcha.
    https://wordpress.org/plugins/contact-form-7-honeypot/
    Concept of honeypot is as – most of the spams are not always manual. Most of them are bot submitted. Honeypot introduces extra field in form. Bots fill this extra field regardless it’s necessity. If this extra form field is filled then form not validate.
  2. Redirect to another url after submissions- Normaly to show thank you page.
    In additional setting tab put following line of code.

    on_sent_ok: "location = 'http://example.com/';"

    Where locations is page url where you want to redirect after submission.

  3. Allow shorcode in Contact Form 7: Put following PHP code in functions file and allow WordPress shortcodes to work in CF7.
    add_filter( ‘wpcf7_form_elements’, ‘custom_wpcf7_form_elements’ );
    
    function custom_wpcf7_form_elements( $form ) {
    $form = do_shortcode( $form );
    
    return $form;
    }
    
    /******************OR****************/
    
    add_filter( 'wpcf7_form_elements', 'do_shortcode' );
    
  4. Pre-populate Contact Form 7: “Contact Form 7 Dynamic Text Extension” adds dynamic content capabilities to Contact Form 7.
    https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/

Why WordPress

As a developer if I ever have to choose from any one of the available CMS,Framework or any other web development prototype; no doubt First one will come in my mind is WordPress.

So why WordPress? Here are some reasons:

  1. Its free : WordPress is contributed by volunteers and available for use absolutely free.
  2. There are thousands of free plugins and themes available for free. One can easily choose from and use.
  3. Simplicity will always be a key factor in success of WordPress. Whether in its use or development.
  4. WordPress permalink structure makes it Search engine friendly.
  5.  Highly maintainable as updates and upgrades are very easy; even automatized.
  6.  Development for and using WordPress is very easy and efficient.
  7. Recent developments like REST API integration in core makes it very promising tool for mobile app development.

WordPress is continuously proving that its not only a Content Management System or Blogging tool but can be used to develop an app or provide services to an app.