# Bulk add to Group limitations

**URL:** https://meta.discourse.org/t/bulk-add-to-group-limitations/73626
**Category:** Support
**Created:** [November 7, 2017, 7:35pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626 "2017-11-07T19:35:57Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 7, 2017, 7:35pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/1 "2017-11-07T19:35:57Z")

</div>

Hi there,

A little about what I’m trying to do.

We are planning to lock down content to our Forums and we want to use the Bulk Add to Group feature so that we can paste in a list of specific list of users who are premium Subscribers. We have close to 30K users so I was wondering what’s the maximum number of emails I could paste into that field and expect the feature to work?

Thanks for your help in advanced.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 7, 2017, 8:07pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/2 "2017-11-07T20:07:57Z")

</div>

You bulk add with a CSV, but that’s almost certainly a bad idea.

You probably want to use SSO to authenticate against that user database instead of trying to maintain two of them.

---

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 7, 2017, 8:31pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/3 "2017-11-07T20:31:02Z")

</div>

Hello @pfaffman ,

Thanks for responding to me. I need to do a one-time large bulk add. After that everything will be maintained through the API and new one’s will be added or removed depending on our business logic. We have the latter part working already but wanted to know if there was an option to do a large bulk add to group.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 7, 2017, 8:32pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/4 "2017-11-07T20:32:47Z")

</div>

With the CSV you can assign to groups. I think that’s what you want.

---

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 7, 2017, 8:35pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/5 "2017-11-07T20:35:23Z")

</div>

Hey @pfaffman

Where is the CSV import option you mention? I don’t see that on the Groups menu item.

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [November 7, 2017, 8:43pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/6 "2017-11-07T20:43:45Z")

</div>

> [@Sending bulk user invites](https://meta.discourse.org/t/sending-bulk-user-invites/16468):
>
> bookmark This guide explains how to invite multiple users to your Discourse instance using a bulk invite feature. person_raising_hand Required user level: Administrator Inviting a large number of users to your Discourse instance can be time-consuming if done individually. Fortunately, Discourse offers a bulk invite feature that allows you to invite multiple users at once. This guide will walk you through the process of sending bulk invites. information_source It is not possible to in…

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 7, 2017, 9:58pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/7 "2017-11-07T21:58:24Z")

</div>

Good one, @Trash.

Oh, but he said he wasn’t doing SSO?

> [@kmg-yrabelo](#):
>
> After that everything will be maintained through the API and new one’s will be added or removed depending on our business logic.

Perhaps there are factors that haven’t been communicated here, but it’s hard to imagine how SSO isn’t what is needed here.

Anyway, here’s what the invites page looks like if SSO isn’t turned on.

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/8/a830237c7c13f3c793f19ef22b345a7a228f9020.png)

---

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 8, 2017, 1:53pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/8 "2017-11-08T13:53:15Z")

</div>

Good morning, @pfaffman,

I realize now that I didn’t do a good job explaining what I wanted to do. We have SSO working via the WordPress plugin and everyone of our customers have an account on Discourse, too. We are sort of segmentating our content and we want to start locking down content on the forums via Groups.

Almost everyone who has a Discourse account right now will be part of our Premium Content group. Once we start segmenting our content, groups will be added via the API to their Discourse account depending what product they purchase. We need a way to add a Group to about 30k members with an account and we are looking for the most efficient way to do this.

The invites sounds like the right option if they didn’t already have an account, but in this case they already have an account and are able to access all parts of the forum.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 9, 2017, 12:14am UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/9 "2017-11-09T00:14:26Z")

</div>

Rather than add groups via the api you can send group add/delete in the SSO load. That’s sort of the point of SSO, so if you have SSO properly configured, you don’t need to do anything.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [November 9, 2017, 4:06am UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/10 "2017-11-09T04:06:03Z")

</div>

Maybe a custom rake task?

---

<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: [November 9, 2017, 4:20am UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/11 "2017-11-09T04:20:50Z")

</div>

> [@kmg-yrabelo](#):
>
> We have SSO working via the WordPress plugin

There is a filter in the WordPress plugin that you can hook into to add SSO parameters. You could hook a small function into it that would check the date that the user was created on. If they were created before a certain date, then add them to the Premium Content group. If there are some existing users that you want to exclude from that group it would probably be possible to find a way to filter them out.

---

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 9, 2017, 1:17pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/12 "2017-11-09T13:17:39Z")

</div>

@pfaffman

Thanks for the suggestion, but I don’t see a why of doing it that way because the Group will be based on recurring product they will have to buy at our store. These will have to change accordingly to their level of access and I need to be able to add/remove (Which I already have taken care of).

I’m just looking for a way to mark existing users with an account on Discourse that already have access to the Member’s site.

@simon  
Do you know what’s the filter name or in which file/class it might be?

Thank you all for your suggestions, it’s really appreciated.

---

<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: [November 9, 2017, 3:32pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/13 "2017-11-09T15:32:47Z")

</div>

> [@kmg-yrabelo](#):
>
> Do you know what’s the filter name or in which file/class it might be?

The filter is `wpdc_sso_params`

Something like this will add all users who registered before the time that you fist added the function to your site to the ‘premium\_content’ group. You could set the time in the function instead of adding it as an option.

```php
add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params', 10, 2 );
function wpdc_custom_sso_params( $params, $current_user ) {
    add_option( 'your_prefix_membership_cutoff', current_time( 'mysql' ) );

    if ( $current_user->user_registered < get_option( 'your_prefix_membership_cutoff' ) ) {
        $params['add_groups'] = 'premium_content';
    }

    return $params;
}

```

---

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 9, 2017, 5:45pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/14 "2017-11-09T17:45:28Z")

</div>

@simon

That will do the trick for me. What sort of data can I pass to $params[‘add\_groups’] ?

Can I do any of these?

`$params['add_groups'] = 'free';`

`$params['add_groups'] = array( 'free', 'premium' );`

```
// Discourse Group IDs
$params['add_groups'] = array( 2, 3 );

```

Thank you.

---

<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: [November 9, 2017, 5:57pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/15 "2017-11-09T17:57:00Z")

</div>

> [@kmg-yrabelo](#):
>
> What sort of data can I pass to $params[‘add\_groups’] ?

A comma separated list of group names, not an array.

`$params['add_groups'] = 'free,premium';`

From looking at the code, it seems that adding a space in the comma separated list could cause a problem;

---

<div class="post-metadata">

### Author: ![kmg-yrabelo](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kmg-yrabelo](https://meta.discourse.org/u/kmg-yrabelo)
#### Post date: [November 10, 2017, 3:43pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/16 "2017-11-10T15:43:10Z")

</div>

Thanks, Simon.

I’ll use that and add the Group when they initially login.

---

<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: [December 31, 2019, 3:17pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/17 "2019-12-31T15:17:02Z")

</div>



---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [December 31, 2019, 5:47pm UTC](https://meta.discourse.org/t/bulk-add-to-group-limitations/73626/18 "2019-12-31T17:47:18Z")

</div>


