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.
That´s super! Very easy! Thanks!
Was this the reason some of the links here on the BP site were popping up 404 as https://buddypress.org/blahblah/MEMBER_SLUG/etc ?
Cyndy – no, that was a left over from the RC1 version, those should be fixed now.
Thanks for setting these up to be customizable!
Thank you Andy, for your help.
Is it possible to get rid of MEMBER_SLUG in URL?
Use an empty member_slug…
For eg.: https://buddypress.org/apeatling/
Also I tried to change default admin username to something else in the DB and it did not work.
[…] Customizable slugs in BuddyPress […]
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?
@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?
@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)
I’ll test this again on testbp.org – but locally it seems to be working ok for me.
@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
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.
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!
[…] las URLs de BuddyPress Con el reciente lanzamiento de la versión 1.0 de BuddyPress, Andy Peatling ha aprovechado para compartir con nostros un truco para que podamos personalizar las […]
@ 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?
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?
with the slugs active the icons in profile menu “activity”, “blogs”, “wire” etc. don’t appear…
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.
Personalizzare i link di BuddyPress…
Finalmente siamo arrivati alla versione 1.0 di BuddyPress, tale versione viene considerata come stabile, quindi possiamo passare ad un passo successivo e quindi condividere qualche informazione per personalizzare al meglio e come piu’ si preferis…
[…] You can now customizable pageview slugs in BuddyPress. […]
Realy greats!!
But what is the slug for the blog and not the blogs (BP_BLOGS_SLUG) .
the slug for the blog is: BP_HOME_BLOG_SLUG
How would I use this to incorporate a link to my Forum on the homepage?
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.
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?
That’s really superb the suggestive url are really good for members they can easily find out what they are looking for.
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?
@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).
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.
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…
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.
[…] Andy Peating here. (This has only taken a half day of thinking and searching. I’m a little slow, ya know.) […]
[…] Andy Peating here. (This has only taken a half day of thinking and searching. I’m a little slow, ya know.) […]
Wow I am so amazed at the responses! I guess thanks for the help!
this doesn’t work at all.
if you set this in your config, stuff like highlighting etc won’t work. kind of useless.
Thanks buddy.. it helped me a lot.
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).
I forgot to mention that I use WordPressMU v2.9.1 and BuddyPress v1.2
@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
@everyone with problems, please post your issues on the buddypress.org/forums.
Not many people will see your issues here.
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 😉
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 🙂
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/ ?)
doesnt work!!! as usual. What is the ‘overwrite’ order for slugs? do they get overwrited if they appear somewhere else? why?
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/?
define ( ‘BP_ENABLE_ROOT_PROFILES’, true );
enable http://domain.com/username/?
At first it wasn’t working, then I put it in my bp-custom.php file, and voila!
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.
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.
I copy paste the code in wp-config.php file before stop editing and it is showing error.
Parse error: syntax error, unexpected ‘?’ in /home/content/65/8704265/html/wp-config.php on line 1