I've a WordPress multi-site network with 20+ sites. and i'm using gravity forms for Contact/Signup/Subscription forms. I would like to create global form for my wordpress multisite installation. Is it possible that gravity forms save the form entries only into the main/parent site? I've tried using switch_to_blog()
in children sites. but it is not working.any help would be appreciated :)
If you duplicate the form into all sites, you can make them all send their data to the main site by including this on the 'child' 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;
}
Gravity forms stores data based on blog database table prefix,
in multisite all sites uses the same database but data are separated based on table prefix, the prefix are something like, wp_1_, wp_2_, wp_3_.....
if you have a site, like my.blog1.com with table prefix, wp_1_, gravity form store all the form entries of my.blog1.com to wp_1_rg_lead, wp_1_rg_lead_detail, wp_1_rg_lead_detail_long,
Now if you want to save those details on your parent install, you need to play around with the database and modify gravity form using hooks like gform_pre_submission
or gform_after_submission
This post might help http://www.endocreative.com/save-gravity-forms-data-custom-database-table/
© 2022 - 2024 — McMap. All rights reserved.
GFAPI::add_entry($entry);
? – Pip