Rango Rango - 1 year ago 366
PHP Question

How to keep uploaded file or attachment on server directory contact form 7

I am working on a blog where I am using contact form 7. But I need these info to save into db and want to show in user profile with attachment also. As cf7 upload images or attachment temporary in wpcf_upload folders.
I can save all data in custom table by this:

add_action( 'wpcf7_before_send_mail', 'save_application_form');

So first i have to keep images or attachment of cf7 permanently on server.

So please tell me how to do it?


Answer Source

I would suggest you to create your own custom post type to handle user profile, and then create a side bar widget or something to submit the data,

But if you want to save wpcf7 data, insert the below code inside your function.php file,

Make sure you create your custom table,

add_action('wpcf7_before_send_mail', 'save_application_form' );

function save_application_form($wpcf7)
    global $wpdb;
    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $submited = array();
        $submited['title'] = $wpcf7->title();
        $submited['posted_data'] = $submission->get_posted_data();
    $data = array(
        'name' => $submited['posted_data']['name'],
        'email' => $submited['posted_data']['email']
    $wpdb->insert($wpdb->prefix . 'your_table_name', array(
        'form' => $submited['title'],
        'data' => serialize($data) ,
        'date' => date('Y-m-d H:i:s')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download