• Resolved francoiscarsys

    (@francoiscarsys)


    Hello,

    Is it possible to run a php code when the user submits the form?
    I need the information from the form to be added in a sql database.

    I already have a plugin to insert php, but if i just put it in ‘additional settings’, it doesn’t work.

    [insert_php]
    my code to add form to sql database
    [/insert_php]

    https://wordpress.org/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I need the information from the form to be added in a sql database

    you can save your form information into a DB without writing a code 🙂

    See Contact Form DB

    Thread Starter francoiscarsys

    (@francoiscarsys)

    Thanks for the tip!
    But I already got it working by adding the following code to the function.php of the plugin:

    add_action(‘wpcf7_mail_sent’, ‘your_wpcf7_mail_sent_function’);

    function your_wpcf7_mail_sent_function($contact_form) {
    $title = $contact_form->title;
    $submission = WPCF7_Submission::get_instance();
    $posted_data = $submission->get_posted_data();

    if (‘Form name’==$title) {
    MY PHP CODE!!!
    }
    }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘run php code on submit’ is closed to new replies.