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:
- 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. - Redirect to another url after submissions- Normaly to show thank you page.
In additional setting tab put following line of code.[javascript]on_sent_ok: "location = ‘http://example.com/’;"[/javascript]
Where locations is page url where you want to redirect after submission.
- Allow shorcode in Contact Form 7: Put following PHP code in functions file and allow WordPress shortcodes to work in CF7.[php]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’ );
[/php] - 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/