Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gravity Forms - Global forms for multisite

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 :)

like image 575
Maavuz Saif Avatar asked Nov 20 '15 12:11

Maavuz Saif


People also ask

Does gravity Forms work with multisite?

Gravity Forms will not provide support for a single site within a multisite installation that is not using an Elite or Developer license type. We will continue to provide support for a single site within a multisite that has an Elite or Developer license, but where Gravity Forms is not network activated.

How do you make a multiple page form in gravity Forms?

Open the Gravity Forms form builder and under Standard Fields you will find the field Page. Simply drag and drop this field into the page editor to add page breaks to your form… Depending on the length of your form, you can then add further page breaks to increase the number of form pages. It's that simple!

Can I embed a gravity form on another site?

Embed a Gravity Form in an iframe on any site. The typical process to embed a Gravity Form on a site where the plugin isn't installed requires: Developing a custom page template with necessary code to output form scripts and styles.

Is gravity Forms no longer free?

Gravity Forms PricingBasic License: $59 per year * Elite License: $259 per year * Pro License: $159 per year * * Gravity Forms updates and support are provided only for the duration of an active Gravity Forms subscription.


2 Answers

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;
}
like image 147
Daniel Flippance Avatar answered Sep 16 '22 23:09

Daniel Flippance


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/

like image 37
silver Avatar answered Sep 20 '22 23:09

silver