Customizable Slugs in BuddyPress

Now that 1.0 is out in the wild and the development style and standards of BuddyPress have been solidified, it’s time to share a few development style posts.

The first one is all about using custom slugs for the built in BuddyPress components.

BuddyPress (by default) functions around the URL structure. That is, when you punch in a particular URL it analyzes that URL and then works out what you are trying to do.

For example, the URL http://example.org/members/andy/messages tells BuddyPress that you are looking at the members area for member andy, and then in the messages component trying to view the newest messages in your inbox. BuddyPress will then perform all its internal checks to make sure you have the credentials to view this page, fetch the messages, then forward onto a template file to display them.

As you can see from that example, slugs in BuddyPress are an integrated part of how the application functions. So how do we change them?

It’s actually as simple as defining the slugs you want to use in your wp-config.php file. All the slugs for every built in component can be changed. Here’s a list of settings you can add (with some alternate slugs already set), that will change the slugs for each component:

It’s just a matter of picking and choosing which slugs you’d like to change. You can then just paste the lines you need for those slugs from above, into your wp-config.php file somewhere before the “Stop Editing!” line.

Fantastic, currently have buddypress powering the last/current 3 sites I’m designing, was achieving this yesterday by changing the slugs in groups and events. I’ve copied the above to my config file and only having issues with the members slug, it displays users/ but not users/membername and causes a redirect loop. Deleted cookies etc, know it should work, anyone else having issues?

This is a great way to minimize both the problems in themeing and a super easy way to customize my site! Thanks again guys, the automattic team has really swung for the fences with both buddypress and P2 theme all at once, way to put the pressure to facebook and twitter, and more so making it super easy for anyone to do the same!

mod rewrite cannot be used to remove /members/ slug, as the
.htaccess already has a wmpu rule that handles those URLs,

Burtadsit suggested that possibly rewriting BP to assume all urls are BP urls first, then if a user is not found, give the url to WP
(as right now the Slug is the only indicator of which url belong to BP and which belongs to WP)

Customizing the slugs is a start but if all the components still have the default names, it gets weird. Seeing the word “Members” in the nav and then seeing the word “users” in the URL could be confusing. Is there a quick way to replace all mentions of the default names or do you have to dig deeper and change them all manually in each component?

When I installed bp, it was redirecting people from /search/ to /members/ (which I turned off anyway). Adding the define rule above for SEARCH to my bp-custom.php fixed it. I just changed the search slug to something else. (I guess by default it is /search/ ?)

Did anyone ever figure out a way to either remove the /members/ slug altogether or write some sort of mod rewrite in the htaccess so that a user could be found by going directly to http://domain.com/username/?