# 我无法在WordPress网站上将用户添加到Discourse论坛中，尽管用户已加入会员

**URL:** https://meta.discourse.org/t/i-cannot-add-user-to-the-discouse-forum-from-a-wordpress-website-when-user-added-in-a-membership/300025
**Category:** Development
**Created:** [2024年三月19日 16:54 UTC](https://meta.discourse.org/t/i-cannot-add-user-to-the-discouse-forum-from-a-wordpress-website-when-user-added-in-a-membership/300025 "2024-03-19T16:54:32Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2024年四月13日 17:44 UTC](https://meta.discourse.org/t/i-cannot-add-user-to-the-discouse-forum-from-a-wordpress-website-when-user-added-in-a-membership/300025/10 "2024-04-13T17:44:59Z")

</div>

这是基本思路。我假设您需要为该函数添加一些条件，以便在用户的角色更改时，并非所有用户都会被添加到版主组。

```php
function add_user_to_discourse_group_on_role_change( $user_id, $role ) {
	$sso_params = array(
		'external_id' => $user_id,
		'moderator' => 'true', // 布尔值 'true' 和 'false' 需要设置为字符串！
		'add_groups' => 'volunteers' // 逗号分隔列表，逗号后没有空格
	);
    DiscourseUtilities::sync_sso_record( $sso_params );
}

```

---

_[View the full topic](https://meta.discourse.org/t/i-cannot-add-user-to-the-discouse-forum-from-a-wordpress-website-when-user-added-in-a-membership/300025)._
