Hook into Contact Form 7

Contact form 7 is a really amazing WordPress plugin developed by Takayuki Miyoshi available for download from http://wordpress.org/plugins/contact-form-7/ Some key features of contact form 7 are:

  • Ajax Form Submission
  • Multiple form
  • Captcha
  • Spam Filter
  • Multilingual and many more.


I am assuming here that you are familiar with Contact Form 7 or have used this plugin at least once or twice.

It’s quite easy to do.  Just create a new folder in your plugins directory ‘wp-content/plugins/‘. You can name it anything you want. Suppose prom_cf7_man. Inside create a new file and name it prom_cf7_man.php . Paste the following line of code in the top of the page.

Now, inside the function “prom_wpcf7_custom”

The above code will save the form value for fname and lname to $first_name and $last_name respectively.

The following code will stop the form from sending email.

You can redirect the page after mail sent using the following code

You can also used an available hook to change properties

The above function check if the current user is an existing author or not. If the user is an author then he/she is redirected to add new post page else is redirected to a thank you page

Published by karunshakya

Been programming in PHP / WordPress for over 4 years. I specialize in theme with Multilingual feature and plugin development and manipulation.