Customizable Slugs in BuddyPress
May 5, 2009 in How To
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.
Mape said on May 5, 2009
That´s super! Very easy! Thanks!
Cyndy Otty said on May 5, 2009
Was this the reason some of the links here on the BP site were popping up 404 as http://buddypress.org/blahblah/MEMBER_SLUG/etc ?
Andy Peatling said on May 5, 2009
Cyndy – no, that was a left over from the RC1 version, those should be fixed now.
Steve said on May 5, 2009
Thanks for setting these up to be customizable!
Boris Khodorkovsky said on May 5, 2009
Thank you Andy, for your help.
Is it possible to get rid of MEMBER_SLUG in URL?
Use an empty member_slug…
For eg.: http://buddypress.org/apeatling/
Also I tried to change default admin username to something else in the DB and it did not work.
Burkie said on May 5, 2009
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?
Andy Peatling said on May 5, 2009
@Boris: Possibly using re-write rules, but not within BuddyPress no.
@Burkie: I just tried changing the members slug, it seemed to work ok, and is working ok on this site (members -> developers). Are you using 1.0?
Sgoetz said on May 5, 2009
@Andy – I’m not so sure the 404 errors are fixed in v1. It sounds like the problem I’m experiencing now – and I went straight to v1 (not upgrade from an RC)
Andy Peatling said on May 5, 2009
I’ll test this again on testbp.org – but locally it seems to be working ok for me.
Burkie said on May 5, 2009
@Andy yeb it’s 1.0 with forum integration also, http://cowork.in. Will re-upload and check files through mediatemple interface to see if there’s any dodgy htaccess files etc
Burkie said on May 5, 2009
I just tested it with 3 other installations and the same issue came about. When I removed define( “BP_XPROFILE_SLUG”, ‘info’ ) it resolved my issue and everything is working currently.
Danstinebaugh said on May 6, 2009
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!
I really love what you guys are doing! Keep it up!
Enlightenmental1 said on May 6, 2009
@ Andy
which rewrite rules would you be referring to?
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)
any thoughts on that?
Arturo said on May 7, 2009
i’ve the same problem as Burkie, i’ve tested the slugs and with
define ( ‘BP_XPROFILE_SLUG’, ‘info’ );
the member’s profile link change and have an infinite loop, but without bp_xprofile_slug all works fine.
any idea Andy?
Arturo said on May 7, 2009
with the slugs active the icons in profile menu “activity”, “blogs”, “wire” etc. don’t appear…
BeLogical said on May 7, 2009
this is pretty sweet, thanks.
To bad it didn’t tie to the component as well and change all the labels site wide.
I am experiencing the same bug as ARturo. I lose the icons when I update the wire slug.
Adrinoe said on May 11, 2009
Realy greats!!
But what is the slug for the blog and not the blogs (BP_BLOGS_SLUG) .
Arturo said on May 12, 2009
the slug for the blog is: BP_HOME_BLOG_SLUG
Mark said on May 14, 2009
How would I use this to incorporate a link to my Forum on the homepage?
Sparksdontflyup said on May 15, 2009
Good to know.
Now how would I go about moving the slugs around from something like:
http://mysote.com/members/user/XXX
where XXX is like wire, activity, ect. to something like:
http://mysite.com/members/XXX/user
again where XXX is like wire, activity, ect and user would be the person’s username.
I need this type of URL structure for a new nav menu I’m making for my site.
Thanks.
PS: Should this be posted in the forums? Hmmm. I’ll go over there and post this there too.
Todd Gill said on May 22, 2009
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?
IT Buzz said on June 4, 2009
That’s really superb the suggestive url are really good for members they can easily find out what they are looking for.
Eddie Gjaltema said on June 5, 2009
I’ve tried de members slug to!
I got the invinite loop, so i googled back to this page
my slug:
define ( ‘BP_XPROFILE_SLUG’, ‘Profiel’ );
Is there yet an solution for this?
Eddie Gjaltema said on June 5, 2009
@Arturo
Icons don’t show up because de link id has changed to “my-SLUGNAME.”
So you could change the css style sheet.
Or find the code that’s causing this (can’t find it yet).
Gunslinger said on June 24, 2009
ok here is my question. I want to add a chat room, can I add a slug for that, and how do I make that slug direct you to the php file that contains the chat?
I am kinda new at php and buddy press and all so, I am sorry for such a dumb question.
WP Freak said on August 10, 2009
When I use this in my wp-config.php file: define ( ‘BP_HOME_BLOG_SLUG’, ‘news’ );
It works for the URL of the main blog, but all of the posts and categories still retain the “/blog” slug that is the default.
I also noticed that in the “permalink” screen in the admin area, that the “custom structure”, “category slug”, and “tag base” are all pre-populated with “blog”.
Is there a way to replace “blog” site-wide? It appears that defining these custom slugs in the config file isn’t working.
Thanks in advance for the advice…
onnobaudouin said on August 10, 2009
on the default buddypress theme i’d like the ‘home’ (i.e. nothing) slug to go the the normal ‘blog’.
I can switch the buttons round no problem but how to make the ‘normal’ wordpress blog the default?
I cannot see anyway to do this.
gunslinger1 said on September 28, 2009
Wow I am so amazed at the responses! I guess thanks for the help!
Jochen said on October 2, 2009
this doesn’t work at all.
if you set this in your config, stuff like highlighting etc won’t work. kind of useless.
logicfire said on December 4, 2009
Thanks buddy.. it helped me a lot.
Patsar said on February 17, 2010
I have the following problem. I put the following configuration definitions in the wp-config.php file:
/** Buddypress Custom Settings */
define(‘BP_DEFAULT_COMPONENT’, ‘profile’);
define(‘BP_DISABLE_ADMIN_BAR’, true);
define(‘BP_BLOGS_SLUG’, ‘technologies’);
define(‘BP_MEMBERS_SLUG’, ‘users’);
Unfortunately only the BP_DISABLE_ADMIN_BAR works.
When I put the same definitions in a bp-custom.php file on the wp-content/plugins folder everything is ok. The members are available at http://www.mysite.com/wpmu/users and the blogs at http://www.mysite.com/wpmu/technologies. From “Members” tab you can access each member at http://www.mysite.com/wpmu/users/username.
The only problem appears in the “Activity” tab where the link to each member is http://www.mysite.com/wpmu/members/username which causes an expected “page not found” error. The strange thing is that if someone post a reply to an activity item the link to that user is correct (i.e. http://www.mysite.com/wpmu/users/username).
Patsar said on February 17, 2010
I forgot to mention that I use WordPressMU v2.9.1 and BuddyPress v1.2
Enrico said on February 21, 2010
@Patsar same for me. Putting custom slugs in wp-config.php does nothing. Using bp-custom.php works though.
I’m on WP 2.9.2 + BP 1.2
r-a-y said on February 22, 2010
@everyone with problems, please post your issues on the buddypress.org/forums.
Not many people will see your issues here.
Justkidding said on May 9, 2010
WP Freak:
Go to \ wp-admin \ Site admin \ Blogs \ Edit your ID=1 blog \ find “Permalink Structure” and delete from structure “/blog”.
It helps me
kReEsTaL said on June 26, 2010
Hello guys,
Thanks to the Buddypress documentation, I successfully changed all editable slugs (in French).
However, a feature is missing imho : the ability to edit the submenus’ slugs, such as “just-me”, “favorites”, etc.
Basically, you still need to edit the core files if you want to edit them, but that’s a ridiculous solution since all changes will disappear during any Buddypress update.
Any plans on making these submenus’ slugs editable in a near future ? Or do you know any plugin or tip which would help with this matter please ?
Thanks a lot
Josh said on November 8, 2010
One issue some people may run into: I don’t use the Buddypress search right now at all. But it still overrides the slug I had for my own search — http://www.lllllllllaaaaaaallalala.com/search/
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/ ?)
michael said on December 8, 2010
doesnt work!!! as usual. What is the ‘overwrite’ order for slugs? do they get overwrited if they appear somewhere else? why?
Jeff Higgins said on January 19, 2011
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/?
Javhy said on June 22, 2011
define ( ‘BP_ENABLE_ROOT_PROFILES’, true );
enable http://domain.com/username/?
Jerry Lee said on December 22, 2011
At first it wasn’t working, then I put it in my bp-custom.php file, and voila!
Sean A said on January 2, 2012
OK I just tried to add the
define ( ‘BP_ENABLE_ROOT_PROFILES’, true );
line to my bp-custom.php file and I still can’t get to remove the “members” slug from my link so it goes to domain.com/username instead.
Any ideas what else I should/could do?
WP3.3 and BP 1.5.2.
John James Jacoby said on January 2, 2012
If it’s a bug, you’ll have better luck opening a ticket with more details at http://buddypress.trac.wordpress.org. If it’s a support issue, open a topic in our support forums.