# 使用SSO批量登录用户？

**URL:** https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184
**Category:** WordPress
**Created:** [2019 年1 月 10 日 12:31 UTC](https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184 "2019-01-10T12:31:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### 作者： ![Rob\_Jeffrey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rob_jeffrey/32/119646_2.png) [@Rob\_Jeffrey](https://meta.discourse.org/u/Rob_Jeffrey)
#### 发布日期： [2019 年1 月 10 日 12:31 UTC](https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184/1 "2019-01-10T12:31:54Z")

</div>

Hello all,

I have a site with SSO between discourse and WordPress. I have a few hundred users on the WordPress side and I want to get them into the discourse system without having to make them log into discourse first to activate the SSO link or my self having to log in manually to each one before handing it over the user.

Is there a way to bulk log in or edit users?

Many Thanks,

Rob

---

<div class="post-metadata">

### 作者： ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### 发布日期： [2019 年1 月 10 日 13:11 UTC](https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184/2 "2019-01-10T13:11:44Z")

</div>

There are topics describing how to configure sso such that users are logged in to Discourse when they log in to wordpress. They will need to log in to wordpress again after they do that, though.

I don’t know that there’s a way to figure out who has logged in to sso and then get them logged in to Discourse.

---

<div class="post-metadata">

### 作者： ![Rob\_Jeffrey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rob_jeffrey/32/119646_2.png) [@Rob\_Jeffrey](https://meta.discourse.org/u/Rob_Jeffrey)
#### 发布日期： [2019 年1 月 10 日 14:22 UTC](https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184/3 "2019-01-10T14:22:59Z")

</div>

Thanks Jay for your reply, yes I have it configured at the moment (users are logged in to Discourse when they log in to wordpress)

The user accounts I want to get into discourse without manually logging each of them in are all fresh accounts I have created but i need to hand them to the user with them already being in the discourse system so I can set them up with the correct bio, badges and groups.

Thanks again Jay

---

<div class="post-metadata">

### 作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### 发布日期： [2019 年1 月 10 日 19:03 UTC](https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184/4 "2019-01-10T19:03:56Z")

</div>

> [@Rob\_Jeffrey](#):
>
> i need to hand them to the user with them already being in the discourse system so I can set them up with the correct bio, badges and groups.

If you are using the [WP Discourse](https://github.com/discourse/wp-discourse) plugin, you can probably accomplish this by writing a script that loops through the users you have created and calls

```plaintext
WPDiscourse\Utilities\Utilities::add_user_to_discourse_group( $user_id, $group_names )

```

for each of the user IDs. See: [https://github.com/discourse/wp-discourse/blob/master/lib/utilities.php#L309](https://github.com/discourse/wp-discourse/blob/master/lib/utilities.php#L309).

There is also a `sync_sso_record` function in that file that could be useful.

---

<div class="post-metadata">

### 作者： ![Rob\_Jeffrey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rob_jeffrey/32/119646_2.png) [@Rob\_Jeffrey](https://meta.discourse.org/u/Rob_Jeffrey)
#### 发布日期： [2019 年1 月 11 日 14:11 UTC](https://meta.discourse.org/t/bulk-log-in-users-with-sso/106184/5 "2019-01-11T14:11:01Z")

</div>

Thanks Simon! I will give this a go but it sounds exactly what I need
