How to Add Users to BuddyPress Groups in Bulk

On a site I’m working on that runs BuddyPress, I created a new group and wanted to add nearly 400 registered users to it. Unfortunately, adding users to BuddyPress groups in bulk is not a core feature. I searched Google for a solution and while the BuddyPress Members Import plugin is recommended in many of the support threads, the feature alone is not worth spending $49.

Continuing my search, I discovered a code snippet published by Alexander on the WPMU DEV forums that works perfectly. To use it, copy the code and add it to a custom WordPress plugin or paste it to your theme’s functions.php file. I added the code to the top of my theme’s functions.php file.

Code Snippet at the Top of my Theme’s Functions.php File

The JavaScript portion of the snippet adds a new item to the Bulk Actions drown-down menu named Add to BP Group.

Add to BP Group Bulk Action Menu Item

Select the users you want to add to a group and select Add to BP Group. A prompt appears asking for the Buddy Group ID you want to assign the users to.

BuddyPress Group ID Prompt

To locate the Group ID, click on the Groups admin menu and click on the group’s name. The URL will look something like this admin.php?page=bp-groups&gid=357&action=edit and the ID is the number that appears after gid=. After entering the ID number, click the Ok button. All of the users you selected will be assigned to that group.

In the comments of the code snippet on GitHub, Strand-C said he wasn’t able to move 165 users at a time and had to move 50 instead. I tested this theory by moving nearly 400 registered users at the same time to a new BuddyPress group and didn’t encounter any issues. Keep in mind that the site I’m working on is relatively new, is running WordPress 4.7, and has very little traffic which could explain why I didn’t have a problem.

Being able to manage BuddyPress groups in bulk should be a core feature. There is at least one open ticket on BuddyPress trac to add Bulk Edit options to Groups. Until these features make their way into BuddyPress, the code snippet above is a free work-around that makes adding users to groups in bulk a lot more convenient.