nukecpower
8/2/2013 - 10:19 AM

Same Gravity Form across Wordpress Multi Sites.

Same Gravity Form across Wordpress Multi Sites.

<?php
add_filter('gform_shortcode_form', 'gform_shortcode_form_mu_override',10,3);

function gform_shortcode_form_mu_override( $shortcode_string, $attributes, $content ){

    global $blog_id, $wpdb;

       

        require_once(GFCommon::get_base_path() . "/form_display.php");
        $new_form = GFFormDisplay::get_form($attributes['id'], $attributes['display_title'], $attributes['display_description'], $attributes['force_display'], $attributes['field_values'], $attributes['ajax'], $attributes['tabindex']);

       

        //replace the new forms action with one to the root site, rather than /sub-site/ which wouldn't process/submit
        $shortcode_string = preg_replace('/action=\'.*#/', 'action=\'/#', $new_form);

    return $shortcode_string;
}