Bulk add to Group limitations


(Yojance Rabelo) #1

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.


(Jay Pfaffman) #2

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.


(Yojance Rabelo) #3

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.


(Jay Pfaffman) #4

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


(Yojance Rabelo) #5

Hey @pfaffman

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


(Daniela) #6

(Jay Pfaffman) #7

Good one, @Trash.

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

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.


(Yojance Rabelo) #8

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.


(Jay Pfaffman) #9

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.


(Stephen Chung) #10

Maybe a custom rake task?


(Simon Cossar) #11

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.


(Yojance Rabelo) #12

@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_Cossar
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.


(Simon Cossar) #13

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.

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;
}

(Yojance Rabelo) #14

@Simon_Cossar

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.


(Simon Cossar) #15

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;


(Yojance Rabelo) #16

Thanks, Simon.

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