# Plugin error: add\_user and remove\_user not working

**URL:** https://meta.discourse.org/t/plugin-error-add-user-and-remove-user-not-working/150191
**Category:** WordPress
**Created:** [May 2, 2020, 5:40pm UTC](https://meta.discourse.org/t/plugin-error-add-user-and-remove-user-not-working/150191 "2020-05-02T17:40:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Julien\_Kmeo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/julien_kmeo/32/132955_2.png) [@Julien\_Kmeo](https://meta.discourse.org/u/Julien_Kmeo)
#### Post date: [May 2, 2020, 5:40pm UTC](https://meta.discourse.org/t/plugin-error-add-user-and-remove-user-not-working/150191/1 "2020-05-02T17:40:26Z")

</div>

Hi, whenever I call the 2 functions, add\_user\_to\_discourse\_group and remove\_user\_from\_discourse\_group :

```
$user = get_user_by('id', $data["member_id"]);
error_log("Call add_user_to_discourse");
$result = DiscourseUtilities::add_user_to_discourse_group($user->ID, $discourse_group);
error_log(print_r($result, true));

```

I get these error messages :

```
[02-May-2020 17:32:23 UTC] Call remove_user_from_discourse_group
[02-May-2020 17:32:24 UTC] WP_Error Object

(
    [errors] => Array
        (
            [wpdc_response_error] => Array
                (
                    [0] => An error was returned from Discourse while trying to sync the sso record.
                )

        )

    [error_data] => Array
        (
        )

)

```

Could you help me please ? 🙂

---

<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: [May 2, 2020, 6:06pm UTC](https://meta.discourse.org/t/plugin-error-add-user-and-remove-user-not-working/150191/2 "2020-05-02T18:06:38Z")

</div>

It seems likely that this is an authentication error. On the [WP Discourse](https://github.com/discourse/wp-discourse) Connection Options tab, make sure that you are using an All Users Discourse API Key and your site’s system user for the Publishing Username (this defaults to `system`.)

---

<div class="post-metadata">

### Author: ![Julien\_Kmeo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/julien_kmeo/32/132955_2.png) [@Julien\_Kmeo](https://meta.discourse.org/u/Julien_Kmeo)
#### Post date: [May 5, 2020, 5:10pm UTC](https://meta.discourse.org/t/plugin-error-add-user-and-remove-user-not-working/150191/3 "2020-05-05T17:10:07Z")

</div>

Thank you Simon, it worked perfectly !

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 4, 2020, 5:10pm UTC](https://meta.discourse.org/t/plugin-error-add-user-and-remove-user-not-working/150191/4 "2020-06-04T17:10:24Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
