+44 0330 223 3428
Call Us
+44 0330 223 3428

WPTavern: How to Add Users to BuddyPress Groups in Bulk

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

Source: WordPress

Related Post
Matt: On React and WordPress

Matt: On React and WordPress Big companies like to bury unpleasant news on Fridays: A few weeks ago, Facebook announced they have decided to dig in on their patent clause addition to the React license, even after Apache had said it’s no longer allowed for Apache.org projects. In their words, removing the patent clause would […]

Read more
WPTavern: First WordCamp Dublin Set for October 14-15

WPTavern: First WordCamp Dublin Set for October 14-15 photo credit: Ireland.com Following up on the success of WordCamp Belfast last October, the WordPress community in Dublin will be hosting its first WordCamp October 14-15. Both camps began the early stages of planning last year and the two communities have shared some of the same organizers […]

Read more
WPTavern: GitHub Partners with Facebook to Release Atom-IDE

WPTavern: GitHub Partners with Facebook to Release Atom-IDE GitHub announced the launch of Atom-IDE this week, a new set of packages that extend its open source JavaScript-powered code editor to include IDE-like functionality. This first release includes packages that support TypeScript, Flow, JavaScript, Java, C#, and PHP. “The start of this journey includes smarter context-aware […]

Read more

Leave a Reply

Your email address will not be published.