Skip to content

Instantly share code, notes, and snippets.

@thinkstylestudio
Created February 27, 2013 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkstylestudio/5052129 to your computer and use it in GitHub Desktop.
Save thinkstylestudio/5052129 to your computer and use it in GitHub Desktop.
http://www.gravityhelp.com/forums/topic/multisite-2#position-9 I didn't want to edit the plugin directly so tried to find an alternative way to display the main sites forms on sub sites. In the end I used the gravity forums shortcode filter. To pretty much output my own forms setting my own database prefix. I had trouble with the form submit so …
<?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;
$old_wp_prefix = $wpdb->prefix;
$wpdb->prefix = 'wp_';
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']);
$wpdb->prefix = $old_wp_prefix;
//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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment