How to add Custom Shortcode on Contact Form 7

A Brief Introduction to Contact Form 7

Contact Form 7 is one of the most popular and extensible plugin that exists as free plugin in WordPress Plugin Repository. At the point of writing it’s been downloaded 21 Million times and have an average rating of 4.4. Isn’t that amazing?

Contact Form by default comes with lot of salient features as:

  1. Easy to implement form
  2. Top Notch Validations
  3. Easy to add attachments
  4. CAPTCHA
  5. Akismet spam filtering etc

In most cases default forms works fine.

But this is blog is based on my experience on extensibility of the plugin to add a new feature during some custom wordpress development. Adding custom feature in Custom Form 7 is relatively easy, as it’s been well built within coding standards and well maintained and updated.

So How to add a custom shortcode?

I am sharing a snippets that adds the custom shortcode my_custom_shortcode , hereby:

<?php

//create a shortcode my_custom_shortcode
wpcf7_add_shortcode('my_custom_shortcode', 'my_custom_shortcode_function', true);

function my_custom_shortcode_function(){
	// do my things here
}

?>

Hope it helps.

 


About Author

I am Robin - WordPress Developer based in Sydney. I work as Digital Developer. I do some projects now and then, and love blogging about WordPress and Web Design.