# @Smokey rightly pointed out that my "solution" to force enable comments on posts made via XML_RPC from the micro.blog apps was too draconian. Essentially it enabled comments on anything, regardless of how it was posted or updated, and was a quick and dirty workaround.
It "worked" but not in the way it should.
I, therefore, wanted to find a way to only force enable comments on new posts made specifically by this method and not post updates. I think the following code works:
add_action ('xmlrpc_call', 'check_new_post' );
function check_new_post( $method ) {
if( 'wp.newPost' === $method ) {
add_filter( 'wp_insert_post_data', 'open_comments', 100, 1 );
}
}
function open_comments ($postarr) {
$postarr[comment_status] = 'open';
return $postarr;
}
This checks if the wp.newPost
method is called when an xml_rpc call is made - if so it adds the filter to open the comments.
I've updated the plugin here if you want to try it and would appreciate any feedback. It's still experimental but seems to work for me.