using 1 form shortcode (si or cf7) for all multisite sites [closed]

I have a network with more than 50 sites.
I want to create one contact form (which means one shortcode) using contact form 7 or fast secure contact form.
Then, I want to use that shortcode on all the 50+ sites so all sites use the same form.

The problem is that when I try to use a shortcode of site A over site B, it’s not working.

Do you know how can I use a contact form shortcode globaly on all sites at once?

Thanks!

1 Answer
1

A Must Use plugin could do the work.

This is just an outline and has to be fully tested:

add_shortcode( 'global_form', 'shortcode_wpse_87634' );

function shortcode_wpse_87634() 
{
    // Main site, ID=1, that has the form
    switch_to_blog( 1 );

    // Do your stuff
    $my_stuff = something(); // maybe do_shortcode

    // Back to original site
    restore_current_blog();

    // Return shortcode content
    return $my_stuff;
}

Also, maybe the contact form plugin must be Network activated for this to work.
Having the shortcode available Network-wide will work with the mu-plugin, but to have the form really working globally, that’s another issue.

Leave a Comment