WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form DB
[resolved] Save data from multiple forms to the same "table" - feature request (3 posts)

  1. Daniele Raimondi
    Member
    Posted 1 year ago #

    Hi Michael,
    I've read in the forum about the request to save data from multiple forms to the same "table" (i.e, with the same form name).
    I'm developing a 6 langs site for a hotel and I have to duplicate the reservation form 6 time, one for each language, but I'd like to see the posted data, all together, in one place in the backend.

    So I've made some little changes in your plugin, in CF7DBPlugin.php, function saveFormData($cf7).
    In short, I've added the form title among the data passed to the 'cfdb_form_data' filter, so I can use this filter to modify the form title just before data are written to the db.

    Do you think you can add this patch to a future release of your great plugin? I think it could be useful.

    http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/

  2. Daniele Raimondi
    Member
    Posted 1 year ago #

    I've tested it a little bit and I think it really usefull. Here is an example on how you could use this feature:

    //CF7 Forms - data convergence
    //data from 'key' will be saved with 'value' form name
    //TO DO: add this in the theme options panel or somewhere
    //else in the backend
    $my_form_data_aliases = array (
    	'Reservations (IT)' => 'Reservations',
    	'Reservations (EN)' => 'Reservations',
    	'Reservations (DE)' => 'Reservations',
    	'Reservations (FR)' => 'Reservations',
    	'Reservations (ES)' => 'Reservations',
    );
    
    /**
     * Save data posted from multiple forms
     * under the same form name in the db
     * using a filter of cfdb plugin
     */
    
    //Save several forms data to same "virtual table" (i.e wit the same table name in the db)
    function form_data_convergence($cf7) {
      global $my_form_data_aliases;
    	if (key_exists($cf7->title, $my_form_data_aliases)){
    		//Optional: save the filled post name
    		$cf7->posted_data['source_form']=$cf7->title;
      	  	$cf7->title=$my_form_data_aliases[$cf7->title];
        	}
      return $cf7; // be sure to return it
    }
    if ( isset($my_form_data_aliases) && is_array($my_form_data_aliases) && count($my_form_data_aliases) ) add_filter('cfdb_form_data', 'form_data_convergence');
  3. vanted
    Member
    Posted 1 year ago #

    Hi and thanks Michael for a great plugin!

    This feature is exactly what I need and would be really useful. Would organize submissions from multilingual forms nicely. The code above is exactly my use case also.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.