WP CLI BuddyPress – 2.0

BuddyPress 7.0 will come with several updates for the 2.0 version of the wp-cli-buddypress package.

For those of us living in the command line, it is important to have a tool to facilitate tasks that would require several clicks, tabs, and time. That’s the beauty of WP-CLI, you can perform those tiresome tasks from the command line without much hassle.

Taking advantage of this technology, the Buddypress team created a CLI package to perform those tasks. The 1.0.0 version was launched in 2014 and since then, a lot of changes were made to make it better and more stable.

Since we lauched the 2.0 version a few weeks ago, I’d like to share a few things that were changed, improved, and fixed.

New Commands

We are introducing a few more commands to the package that might be helpful. Mainly:

wp bp group meta

The group meta command can be used to manage BuddyPress Group Meta (custom fields). Here a few commands that can be used to manage the meta information from a group:

$ wp bp group meta
usage: wp bp group meta add <id> <key> [<value>] [--format=<format>]
   or: wp bp group meta delete <id> [<key>] [<value>] [--all]
   or: wp bp group meta get <id> <key> [--format=<format>]
   or: wp bp group meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>]
   or: wp bp group meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
   or: wp bp group meta pluck <id> <key> <key-path>... [--format=<format>]
   or: wp bp group meta update <id> <key> [<value>] [--format=<format>]

wp bp activity meta

Just like the wp bp group meta command, the activity meta command can be used to manage BuddyPress Activity Meta (custom fields).

wp bp tool signup

This command can be used to activate or deactivate the BuddyPress signup feature.

$ wp bp tool signup 1

wp bp scaffold tests

This command can be used to create BuddyPress specific testing code for plugins. It is targeted at BuddyPress plugin authors that need to set up BuddyPress specific unit tests.

Package Improvements

We made some major internal changes. The big one was removing our legacy Behat set up. We opted to use the WP-CLI composer package: wp-cli/wp-cli-tests.

This was an important change since we don’t need to manage that ourselves, also outsourcing that job to that package, we can benefit from changes and improvements made there. This package is also used in several, if not all, WP-CLI core packages.

Contributions will be much easier now since they won’t need to understand our previous custom set up.

Other Improvements

Besides those new commands and major internal changes, we took the time to improve the code base for reliability:

  • we bumped the PHP version from PHP 5.4 into PHP 5.6.
  • we made sure all Behat tests were passing correctly, fixing bugs where we found them.
  • we improved the readme documentation to better explain a few commands.
  • we forced the creation of the signups table when using the wp bp signup command. This was important in cases where the table was not present and would cause the CLI to fail.
  • we also updated the commands to return proper success/error messages when using tge parent::_delete or parent::_update helper methods.
  • we improved the commands PHPDocs: very useful when using the help param to find out what a command does.
  • we updated to fetch values from PHPDoc instead of PHP.
  • updated or removed the default values from several commands (most of them were wrong, lol).

And several other minor changes to improve the codebase and make sure the commands would run smoothly.