# I cannot add user to the discouse forum from a wordpress website when user added in a membership

**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:** [March 19, 2024, 4:54pm 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:** 8

<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:** [March 19, 2024, 8:41pm 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/8 "2024-03-19T20:41:42Z")

</div>

> [@Haseeb\_Ahmed](#):
>
> it is adding user into volunteers group but not in the moderators

You can’t add users to the “moderators”, “admin”, or “staff” groups with this function call. Technically, you can’t add users to any “automatic” groups with this approach. You can only add users to custom groups that you have created.

Edit: if you need to add users to the moderators group, have a look at the `sync_sso_record` function: [https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L70-L81](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L70-L81). The `add_user_to_discourse_group` function is just a convenience wrapper around `sync_sso_record`.

`moderator` (`boolean`) is an accepted argument for the SSO params: [discourse/lib/discourse\_connect\_base.rb at 5098338a9649ee8830c8a0781e0eb538e8206eac · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/5098338a9649ee8830c8a0781e0eb538e8206eac/lib/discourse_connect_base.rb#L13-L43). You could also add any custom groups that you want to add users to by using the `add_groups` param. That would allow you to add a user to the “moderators” group and the “Volunteer Members” group with a single API call.

Edit 2: If you try the `sync_sso_record` function approach, you might need to use the string `"true"` instead of the boolean `true` for the `moderator` param. PHP interprets `true` as `1`. I think Discourse accepts the string `"true"` to deal with that case. Note that you can use the `get_sso_params` function to set the SSO params: [https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L129](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L129). There’s an example of how to do that in the `add_user_to_discourse_group` function’s code.

---

_[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)._
