HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Create Discussion programmatically
Hi,
Our client has extreme customization needs . Is there a way to do create it through code?
Thanks
0
Comments
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.
/profile/tokens
page./setting/swagger
Feature.AuthenticationAPI.Enabled
) and a/api/v2/tokens/oauth
endpoint in progress that would allow certain SSO setups to generate access tokens.The reason why I was looking for ways to create discussions through code is...
Thanks
You only need to enhance the normal "new discussion" process to achieve that.
The category drop downs need some Javascript and the related discussion would need some ajax and a way to find out what is a related discussion
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.