Our client has extreme customization needs . Is there a way to do create it through code?
Yes, there are several ways I'd say. Determining the best approach requires more knowledge of the exact requirements/why a discussions should be created through code. Here is what I can think of:
You can do it with SQL (bad)
You can use the framework from external code (not that good either)
You can write a plugin that offers an endpoint for creating such a discussion (security issue if done wrong)
You can use the API,but you would need to handle the tokens by yourself (cleanest approach)
But if possible, share the requirements so that we can give better advice.
I'd definitely recommend using the API.
The reason why I was looking for ways to create discussions through code is...
You only need to enhance the normal "new discussion" process to achieve that.
The Sphinx search plugin has a "related" feature, as far as I know. I can post some example code later on this weekend, but I already made something similar to the category thing and that old plugin might be an example, not really a blueprint. Search my GitHub repos for "WordPress". There should only be one repo with that string.