Yes, it’s possible. You can make any API request to Discourse from Wordpress using the discourse_request
utility method, i.e.
use WPDiscourse\Utilities\Utilities as DiscourseUtilities;
$args = array(
"body" => "",
"type" => "post"
);
$response = DiscourseUtilities::discourse_request( $path, $args );
This will format the request correctly and use the API key and user you’ve provided in the WP Discourse settings. You’ll need a global key for the actions you’re referring to (if you’re also using the same key for normal wp discourse functionality).
Creating a group
The endpoint you want is this: Discourse API Docs. There isn’t a full list of the params in the api docs, but you’ll find them here: discourse/groups_controller.rb at main · discourse/discourse · GitHub
Creating a catetgory
The endpoint you want is this: Discourse API Docs. Likewise the full param list is here: discourse/categories_controller.rb at main · discourse/discourse · GitHub
Note that the “securtiy settings” are handled via the permissions
param. You just need to give it an object with group names as the keys and permission level integers as the values, e.g.
{
"cohort1": 2,
"staff": 1
}
You’ll find the permission level integer list here: discourse/category_group.rb at main · discourse/discourse · GitHub