Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] View/edit an already submitted form with default values

  • Hi,

    First of all, thank you for a great plugin! 🙂

    I want to (on a new fresh PHP-page) display an already submitted form with the submitted values used as default values on that form so the user can edit his/her submitted values afterwards. This page will be accessed via an URL like:

    To make it easier, I have created a new column in the submits-table called “unique_id”, so each submit have a unique ID (i have tweaked the INSERT INTO-code in db-extension to achieve that).
    So my table data looks a little bit like this for the submits-table:

    unique_id submit_time form_name field_name (and so on...)
    1 1288698294 form-name name ...
    1 1288698294 form-name email ...
    2 1288701853 second-form name ...
    2 1288701853 second-form email ...

    This is what i’ve got so far in the edit_form.php:
    require_once './wp-blog-header.php';

    $unique_id = $_GET['unique_id']; // The "unique_id" value (ex. 1)

    // Get any necessary values from "submits" and "wp_contact_form_7" tables
    $form = $wpdb->get_row('
    SELECT f.cf7_unit_id id
    FROM wp_contact_form_7 f
    ON f.title = s.form_name
    WHERE s.unique_id = ' . $unique_id . '
    LIMIT 1

    $contact_form = wpcf7_contact_form($form->id);

    echo $contact_form->form_html(); // Display form

    This code only displays the submitted form, but I don’t know how to insert the already submitted values from the DB into the form, and then let the user be able to submit it again. Is this already “invented”, or can somebody help me out here?

    Thank you!

  • The topic ‘[Plugin: Contact Form 7] View/edit an already submitted form with default values’ is closed to new replies.