For the past two weeks, I’ve been helping a friend build his site. The site uses WordPress and BuddyPress and is the first opportunity I’ve had to use BuddyPress for a project. The site is dedicated to a Hockey League league that’s specific to a video game. The league has a number of players and teams.
By default, when a visitor browses a BuddyPress member’s profile, the activity tab is displayed. Since a player’s team is displayed on a user’s profile, I wanted the profile tab to be the first thing users see. According to the BuddyPress Codex, it’s possible to change the default landing tab by adding a line of code to either a bp-custom.php file or to wp-config.php. The code is as follows:
/**
* Change BuddyPress default Members landing tab.
*/
define('BP_DEFAULT_COMPONENT', 'profile' );
As I didn’t want to create and upload another php file, I inserted the code into wp-config.php. At the time of writing this article, the help document on the BuddyPress Codex did not specify where in the wp-config file the code should be placed. After adding the code to the bottom of the wp-config file, I noticed it didn’t work.
The trick is to add it to a place that runs before BuddyPress is fully loaded. I moved the code so that is was after the define(‘DB_COLLATE’, ”); line in wp-config. This allowed the code to run without any issues.
With the code in place, whenever someone clicks on a player’s name that’s mentioned in a post, the first thing they see is their profile and the team they’re assigned too.
This is a small change in how BuddyPress works but for an implementor like me, it was a bit of a hassle. The largest obstacle in achieving what I wanted were the directions that don’t specify where in the config file the code should be placed. I’ve since edited the Codex article to prevent others from experiencing the same trouble.
Related and something I need to pick back up: https://core.trac.wordpress.org/ticket/37199