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:
define ( 'BP_ACTIVITY_SLUG', 'streams' ); define ( 'BP_BLOGS_SLUG', 'journals' ); define ( 'BP_MEMBERS_SLUG', 'users' ); define ( 'BP_FRIENDS_SLUG', 'peeps' ); define ( 'BP_GROUPS_SLUG', 'gatherings' ); define ( 'BP_MESSAGES_SLUG', 'notes' ); define ( 'BP_WIRE_SLUG', 'pinboard' ); define ( 'BP_XPROFILE_SLUG', 'info' ); /* Some other non-component slugs */ define ( 'BP_REGISTER_SLUG', 'signup' ); define ( 'BP_ACTIVATION_SLUG', 'enable' ); define ( 'BP_SEARCH_SLUG', 'find' ); define ( 'BP_HOME_BLOG_SLUG', 'news' );
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.