How to send contact to database using wordpress plugin Contact Form 7?

2 Bitcoin bounty has been announced by author.
0 has been already awarded by author.
2 remains available.

Connecting and insert record to database.

1 Answer

Internet users could send Bitcoin Tips to you if they like your answer!

since Sept 23, 2014 (but maybe the change was made earlier since we didn't update the plugin until then) There are structure and code changes made in the new version which means this will not work. If you don't see the classes.php file you know you have the newer version (4.0 for me). Modify the contact-form.php file around line 560 after:

  if ( $submission->is( 'mail_sent' ) ) {
   if ( $this->in_demo_mode() ) {
    $result['status'] = 'demo_mode';

add your tracking code such as:

require_once (getcwd().'/wsdl/func.php');

on your own code you might need to add [0] at the end of the array fetching for each field.

Otherwise if you have an older version read the original solution:

If you use the quick form creation on wordpress with the popular Contact Form 7 while sending the data (not only to email) to a database of your CRM or related software to help manage the leads, this should help.

Although I am aware of the database extension I couldn't spend time to figure it out because we already had a database solution from a custom site that didn't use wordpress prior, so it was very simple once I found where the data is being sent:

Found the location in our install to be under /your-domain/wordpress/wp-content/plugins/contact-form-7/includes/classes.php

In this file you edit the part which is around line 278 in the submit function under the code

} elseif ( $this->mail() ) {

add your code, in my case it's two lines:


As simple as this you have the data and can send it to your database (which could and probably should be on different host).

User rating:

Thanks Boris, here are some bitcoins on their way to your wallet :)


Too many commands? Learning new syntax? is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with!

Post Answer