V
V
VANY2016-02-14 20:20:20
WordPress
VANY, 2016-02-14 20:20:20

How to run the same Contact Form 7 on multiple blogs?

Wordpress + Multisite.
There are a lot of identical sites both in context and in structure.
They have a feedback page.
At the moment there is the following code:

<?php
$original_blog_id = get_current_blog_id();  //запоминаем текущий блог
switch_to_blog('1');  //переключаем среду на основной блог (там создана форма)
echo do_shortcode('[contact-form-7 id="'.get_field('contact-right-wpcf','option').'"]'); // вызываем форму, подставляя ID (зависит от текущего языка сайта)
switch_to_blog($original_blog_id); // возвращаем текущий блог
?>

Forms render on all sites, but when submitted, the form is only submitted on the main site.
I suspect there is a script hanging somewhere that doesn't understand why the domain doesn't match blog #1.
Any ideas how this can be fixed?
===
Or please suggest a form plugin with which I can call the same submit form on different blogs in the wp network

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Kaspor, 2022-03-04
@this_nicco

They also need to be wrapped in switch_to_blog :

wp_head(); 
wp_footer();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question