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

4 Comments


  1. First of all, Thank you for considering my plugin i.e. BuddyPress Members Import, at least during the review phase. Let me explain why BMI plugin is worth for $49
    – This plugin is not only for Members Import but there are more features available in the plugin to make the process smoother.
    – A good developer charge $49 for less than 2 hours or max 2 hours job.
    – If you are a developer and want to write code for mapping BP users in group then you must have good knowledge in WordPress and BuddyPress then only you can write code for this feature.
    – But not every one is developer or coder.
    – In $49 you are getting
    — Support for 1 year.
    — 1 year free updates.
    — You will use code tested by more than 1000s of plugin users in different scenarios.

    Report


    1. It’s funny how you mentioned that a good developer charges $49 for 2 hours job. You see it is alright if you are doing this for one particular client. In that case it may seem justified. But your product(plugin) is not just going to be used by one client but probably thousands of people, thereby giving you a lot more revenue than $49. So you could have maybe priced it a little lower. GTA V probably took thousands of coders and years of development, but that doesn’t mean each license is going to cost a million dollars(costs same as your plugin). If your aim is to earn certain amount of money from your code which took your time and energy then you should first determine how much do you wanna earn from it. Then how many users will probably buy it and then price it accordingly.

      Report

Comments are closed.