# Ik kan geen gebruiker toevoegen aan het Discourse-forum vanaf een WordPress-website wanneer de gebruiker is toegevoegd aan een lidmaatschap

**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:** [19 maart 2024 om 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:** 3

<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: [19 maart 2024 om 19:17 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/3 "2024-03-19T19:17:12Z")

</div>

> [@Haseeb\_Ahmed](#):
>
> i have created a function to add user to the discourse group when user role change but it is not adding that user into the discourse group

From visiting your site, I think your WordPress site is functioning as the [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) authentication provider for your Discourse site. If that is correct, you can use the `add_user_to_discourse_group` helper function to add WordPress users to Discourse groups: [https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L278-L326](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L278-L326). Details about using the function are here:

> [@Manage group membership in Discourse with WP Discourse SSO](https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724):
>
> [WP Discourse](https://github.com/discourse/wp-discourse) functions The [WP Discourse](https://github.com/discourse/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…

Note the `use` statement at the top of the code example:

```php
use WPDiscourse\Utilities\Utilities as DiscourseUtilities;

```

And how that is then used to call the (static) function:

```php
$result = DiscourseUtilities::add_user_to_discourse_group( $user_id, $group_name );

```

---

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