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.
    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 = '';"

    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;
    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.