Gravity forms - global forms for multisite

I have a multi-user WordPress network with 20+ sites. and I use gravity forms for contacts / registration / subscription forms. I would like to create a global form for my multitasking wordpress installation. Is it possible that gravity forms only store records in the form on the main / parent site? I tried using switch_to_blog() in the switch_to_blog() sites. but it does not work. Any help would be appreciated :)

+6
source share
2 answers

Gravity forms store data based on the blog database table prefix,

in multisite, all sites use the same database, but the data is separated based on the table prefix, the prefix is โ€‹โ€‹something like wp_1_, wp_2_, wp_3 _.....

if you have a site, for example my.blog1.com with the table prefix, wp_1_, the gravity form stores all records of the form my.blog1.com in wp_1_rg_lead, wp_1_rg_lead_detail, wp_1_rg_lead_detail_long,

Now, if you want to save this data in your parent installation, you need to play with the database and change the severity using hooks like gform_pre_submission or gform_after_submission

This post may help http://www.endocreative.com/save-gravity-forms-data-custom-database-table/

+1
source

If you duplicate the form on all sites, you can force them to send their data to the main site by adding this to the "subsidiary" sites:

 $formId = 1; //Put your form id here add_filter('gform_confirmation_'.$formId, 'gform_confirmation', 10, 4); function gform_confirmation($confirmation, $form, $entry, $is_ajax) { //Switch to Main site switch_to_blog(1); //Insert the entry into the main site $new_entry_id = \GFAPI::add_entry($entry); //Switch back restore_current_blog(); //Tidy up by deleting the entry from THIS site $result = GFAPI::delete_entry($entry['id']); return $confirmation; } 
0
source

Source: https://habr.com/ru/post/1236425/


All Articles