# 使用 WP-Discourse 或 API 添加组和类别（带安全）？

**URL:** <https://meta.discourse.org/t/add-groups-and-categories-with-security-with-wp-discourse-or-the-api/212787>\
**Category:** WordPress\
**Created:** [2021年十二月21日 15:35 UTC](https://meta.discourse.org/t/add-groups-and-categories-with-security-with-wp-discourse-or-the-api/212787 "2021-12-21T15:35:18Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)\
**Post date:** [2022年五月17日 12:13 UTC](https://meta.discourse.org/t/add-groups-and-categories-with-security-with-wp-discourse-or-the-api/212787/7 "2022-05-17T12:13:34Z")

</div>

嘿 Tom，要将 Discourse 群组与 WooCommerce 会员资格同步，您需要使用此处所述的方法：

> [@Manage group membership in Discourse with WP Discourse SSO](https://meta.discourse.org/t/managing-discourse-group-membership-with-wp-discourse-sso/74724):
>
> WP Discourse functions The WP Discourse plugin has a couple of functions that can be used to associate WordPress users with Discourse groups. These functions are only enabled on sites that are using WordPress as the SSO provider for Discourse. add\_user\_to\_discourse\_group( $user\_id, $group\_names ) [View Code](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L278-L301) remove\_user\_from\_discourse\_group( $user\_id, $group\_names ) [View Code](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L303-L326) Each of these functions take the same two parameters: $user\_id: the WordPress user’s id $group\_names: a comma separat…

---

_[View the full topic](https://meta.discourse.org/t/add-groups-and-categories-with-security-with-wp-discourse-or-the-api/212787)._
