Bug report: Comment form disappears in multisite
-
I have a script for importing articles into a WordPress multisite. It’s a custom PHP script that is called directly from the command line and
require wp-load.phpat the very beginning to load the WordPress core.For each article to be imported, the
switch_to_blog()function is called to import the article into the correct site. The problem with wpdiscuz is that each time a post is created on a site other than the main site, the comment form disappears for all the articles on that site. To make it reappear, we have to save the wpdiscuz_form post again.To resolve the issue within the import script, I have to reset
WpdiscuzOptions->formContentTypeRelbefore each post, like this:wpDiscuz()->options->formContentTypeRel = get_option("wpdiscuz_form_content_type_rel", []);Here are the traces of what I observed while debugging this issue.
When the plugin loads, the
WpdiscuzOptions->initFormRelations()method is called, which initializesWpdiscuzOptions->formContentTypeRelwith a value from the main site. Whenswitch_to_blog()is executed, this data is not reloaded to obtain the value for the site which has become the current site. Because of this, we end up executing the lineunset($contentRel[$postType][$lang]);in theForm->setFormID()method, which causes comments to stop displaying on the article’s site until we save the wpdiscuz_form post of that site again.I think the permanent fix in wpdiscuz should be to add a hook on
switch_blogto reset the value ofWpdiscuzOptions->formContentTypeReleach time a blog switch occurs.
The topic ‘Bug report: Comment form disappears in multisite’ is closed to new replies.