Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I store the values from a WPForm in WordPress to a MySQL database?

How can I store the values from a WPForm in WordPress to a MySQL database?When we use WPForms where I have to add PHP part to store data? Can we store form data to tables when we are using free version of WPForms without buying it?

like image 880
Ranmal Mendis Avatar asked Oct 20 '25 13:10

Ranmal Mendis


1 Answers

If you are using WP Forms Lite you can't do this directly, either you'll need to upgrade to PRO version or build your own custom save actions.

If you decide to go with your own custom version, some details below on how to intersect form submission on WP Forms.

WPForms has some actions you can use to do you own custom actions after form submission:

  1. wpforms_process_complete

        do_action( 'wpforms_process_complete', $this->fields, $entry, $form_data, $entry_id );
    

By using on your own template or plugin the wordpress hook add_action for any of the events described, you are able to get form data and do the handling you need.

Reference for wordpress add_action can be seen on the official documentation. https://developer.wordpress.org/reference/functions/add_action/

Did a quick snippet that will help you get started:

add_action("wpforms_process_complete", 'function_save_custom_form_data');

function function_save_custom_form_data($params) {

    foreach($params as $idx=>$item) {
        $field_name = $item['name'];
        $fiel_value = $item['value'];
        // Do whatever you need
    }
    return true;

}

Please let me know if you need any further details.

like image 89
josedasilva Avatar answered Oct 22 '25 03:10

josedasilva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!