WP-Discourse: error message and not publishing

(Filippo Corti) #1


I (successfully) installed discourse yesterday, but I don’t seem to be able to connect it with Wordpress. I filled in all the required forms (such as API), but it’s still not posting anything to discourse. Also, I get an error message in the comment section of my blog:

Warning: in_array() expects parameter 2 to be array, boolean given in /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-content/plugins/wp-discourse/wp-discourse.php on line 272

Warning: file_get_contents(/wordpress.json?best=6&min_trust_level=0&min_score=0&min_replies=0&bypass_trust_level_score=0) [function.file-get-contents]: failed to open stream: No such file or directory in /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-content/plugins/wp-discourse/wp-discourse.php on line 167

Any idea or suggestion on how this can be fixed? Thank you :slight_smile:

(Ben T) #2

What have you chosen for allowed_post_types?

Also, what have you used as the url?

(Filippo Corti) #3

I have selected post and revision, and as url I’ve used http://discuss.bicyclemind.it.

(Filippo Corti) #4

I don’t think the two are communicating at all: under logs (inside discourse) nothing gets logged when I publish a new post.

I tried to regenerate the API key but it still does not work.

(Ben T) #5

It appears that it is not correctly generating the URL needed to copy over the comments (the second error you’ve listed above.) Do you run any other plugins/settings in wordpress that change the URL of a post?

(Filippo Corti) #6

Nope, I have a plugin that allows me to create linked-list posts but it doesn’t change the permalink of the posts (the only thing it does it to send the reader, when he clicks on the title of these kind of posts, to the original article).

But anyway it affects just some posts: I tried to use the plugin on normal (non-linked-list) ones and it still does not work.

(Filippo Corti) #7

Sometimes — since I’ve activated the plugin — when I hit the update button of a post, inside wordpress, I get a blank page with this error:

Warning: in_array() expects parameter 2 to be array, boolean given in /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-content/plugins/wp-discourse/wp-discourse.php on line 272

Warning: Cannot modify header information - headers already sent by (output started at /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-content/plugins/wp-discourse/wp-discourse.php:272) in /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-admin/post.php on line 235

Warning: Cannot modify header information - headers already sent by (output started at /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-content/plugins/wp-discourse/wp-discourse.php:272) in /nfs/c09/h04/mnt/140707/domains/bicyclemind.it/html/wp-includes/pluggable.php on line 1121

(Filippo Corti) #8

Solved by ditching the plugin and embedding discourse directly: Embedding Discourse in Static Sites - Evil Trout's Blog

I don’t know if the plugin has any feature I’m missing, but this solution is working fine and not causing all the problems I had with the plugin.

(Sander Datema) #9

I had the same error. Gonna have a look at embedding it.

(Anthony Giovannetti) #10

I might have to do this simply because the plugin is apparently not being maintained. Is there anyway with embedding to be selective on which posts get added to discourse?

(Jeff Atwood) #11

Plugin is maintained, several of our partners use it. Issue is that there are millions of possible wordpress settings and plugins…

(Anthony Giovannetti) #12

I don’t think this excuse is even remotely close to valid. Single devs with half your competence working on harder problems have been able to pump out teeming hordes of wordpress plugins that manage to work just fine.

I don’t want to be overly aggressive/rude here, but to better explain my frustration: I run several plugins on my site, and the Discourse plugin is by far the worst, it actually causes me lots of busy work.

(Jeff Atwood) #13

Works fine for me with the Discourse blog. I guess it depends how you use it?

(Sander Datema) #14

Well, I ‘fixed’ it by hardcoding the allowed post types. Somehow get_option('discourse_allowed_post_types'); returned a boolean instead of an array. So I changed it to $allowed_post_types = [1];

A monkeypatch, but hey, it works.

(Filippo Corti) #15

It depends on what you want. I you want to be able to select it for every single post then it’s pretty hard, if you want just certain categories of your blog to have comments, then just drop into discourse the rss feed of that category and wrap the discourse embed code into this:

<?php if (in_category(37)): ?>
<?php endif; ?>

Where 37 is the ID of your chosen category.