How to enable BuddyPress Root Profile
Are you looking for a way to enable fancy user profile url like https://example.com/user-nice-name instead of the default profile url https://example.com/members/user-nice-name offered by BuddyPress? If yes, this is your day!
By default, BuddyPress offers user profile urls which appear as sub pages of members directory. If you need a fancy url for the user profile where members directory is not part of the user profile url, You can enable Root profile in BuddyPress.
Yes, you heard that correctly! If you need fancy user profile url like twitter, facebook, instagram etc where the user profile url consists of the siteurl and username( eg. https://example.come/user-nice-name/), you can achieve that with BuddyPress by enabling root profile. BuddyPress root profile makes the user profile url appear as direct sub page of the site directly instead of the members directory.
How to enable it?
To enable BuddyPress root profile, Please add the following code in wp-content/plugins/ bp-custom.php file.
define( 'BP_ENABLE_ROOT_PROFILES', true );
If you do not know what is bp-custom.php, Please take a look at https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/
Here is a screenshot showing BuddyPress user profile url before enabling root profile:-
Here is a screenshot showing BuddyPress user profile url after enabling root profile:-
Enabling root profiles might have side effect. If some of your page has same slug as a user's nice name, it will cause conflict. Please do remember this while enabling the root profile.
Have a happy social networking experience with BuddyPress!
I tried this, but what happens is that when Buddy press loads, you see this code. You also see the code on screen when you log out, or go to the plugins tab in the wp back end.
and the user, nevertheless is redirected to his profile at members/username (I use "BuddyPress Login rediret to Profile" plugin)
I am sorry, I see you left out the php syntax, and just gave the code. It does work as
Having implemented this, I find I have a 404 conflict if I set the WP back end permalink structure to be domain/username/year/day/month and post a post. During preview it can be seen, but after publishing it, it gives a 404 if you go to the post url. I think this solution, above in your post, may be causing the conflict, but I can find no one who can work around the problem. Anyone have an idea?