Make Instagram-Style /@username/ URLs in BuddyBoss
BuddyBoss and BuddyPress normally use this profile URL structure:
https://example.com/members/username/
For a social network or community website, you may want a cleaner Instagram-style profile URL like:
https://example.com/@username/
BuddyBoss has documentation for changing profile navigation tab slugs and component slugs, but that only helps with normal slugs such as /members/, /users/, /profile/, or profile tab URLs. It does not natively create root-level @username routing. BuddyBoss profile and component slugs are part of how BuddyPress/BuddyBoss resolves members, profile tabs, groups, messages, and other community screens. (BuddyBoss)
This guide shows a safe code-based method to make:
/@username/
load the real BuddyBoss profile page while keeping BuddyBoss functionality working.
What We Are Building
We want this old BuddyBoss profile URL:
https://example.com/members/webdevayon/
to become:
https://example.com/@webdevayon/
The page should still show the actual BuddyBoss member profile, profile tabs, activities, friends, photos, messages, and other BuddyBoss profile features.
The important part is this:
/@username/
must load the profile page internally, not redirect again and again.
Why BP_MEMBERS_SLUG Is Not Enough
BuddyBoss/BuddyPress allows changing component slugs. For example:
define( 'BP_MEMBERS_SLUG', 'users' );
This can change:
/members/username/
to:
/users/username/
But it cannot create:
/@username/
because @username is not a normal component base slug. BuddyBoss expects a component path like:
/members/username/
So for Instagram-style routing, we need custom URL handling.
Best Method: Use an MU Plugin
Do not add this code inside Elementor, theme customizer, or random header/footer snippets.
Use an MU plugin because it loads earlier than normal plugins and themes.
Create this folder if it does not exist:
/wp-content/mu-plugins/
Then create this file:
/wp-content/mu-plugins/buddyboss-at-profile-url.php
Full Working Code
Paste this full code inside:
<?php
/**
* Plugin Name: BuddyBoss Instagram Style @username URLs
* Description: Converts BuddyBoss profile URLs from /members/username/ to /@username/.
* Author: Webzlo
* Version: 1.0.0
*/
/**
* Internally map /@username/ to /members/username/
* without changing the browser URL.
*/
add_action('muplugins_loaded', function () {
if (is_admin()) {
return;
}
$uri = $_SERVER['REQUEST_URI'] ?? '';
if (preg_match('#^/@([^/?]+)(/[^?]*)?(\?.*)?$#', $uri, $m)) {
$username = sanitize_title($m[1]);
$extra = $m[2] ?? '/';
$query = $m[3] ?? '';
$_SERVER['BB_AT_PROFILE_REQUEST'] = '1';
$_SERVER['REQUEST_URI'] = '/members/' . $username . $extra . $query;
}
}, 0);
/**
* Stop WordPress canonical redirect from breaking /@username/.
*/
add_filter('redirect_canonical', function ($redirect_url) {
if (!empty($_SERVER['BB_AT_PROFILE_REQUEST'])) {
return false;
}
return $redirect_url;
}, 1);
/**
* Change BuddyBoss generated profile links to /@username/.
*
* Important:
* Do not change the domain while internally loading /@username/,
* otherwise BuddyBoss may create a redirect loop.
*/
add_filter('bp_core_get_user_domain', function ($domain, $user_id) {
if (!empty($_SERVER['BB_AT_PROFILE_REQUEST'])) {
return $domain;
}
$user = get_userdata($user_id);
if (!$user) {
return $domain;
}
return home_url('/@' . $user->user_nicename . '/');
}, 1, 2);
/**
* Replace remaining frontend /members/username/ links in final HTML.
* This helps profile menus, widgets, member cards, and some BuddyBoss template links.
*/
add_action('template_redirect', function () {
if (is_admin() || wp_doing_ajax()) {
return;
}
ob_start(function ($html) {
$site_url = home_url();
// Replace absolute profile URLs.
$html = preg_replace(
'#' . preg_quote($site_url, '#') . '/members/([^/"\'<\s]+)/?#',
$site_url . '/@$1/',
$html
);
// Replace relative profile URLs.
$html = preg_replace(
'#/members/([^/"\'<\s]+)/?#',
'/@$1/',
$html
);
return $html;
});
}, 999);
Step-by-Step Setup
Step 1: Remove Old Snippets
Before adding this code, remove any old code related to:
/@username/
or:
/members/username/ redirect
Do not keep multiple versions. Multiple snippets can create redirect loops.
Step 2: Add the MU Plugin
Upload this file:
/wp-content/mu-plugins/buddyboss-at-username.php
You can do this using:
cPanel File Manager
FTP
SFTP
SSH
Recommended path:
public_html/wp-content/mu-plugins/buddyboss-at-username.php
Step 3: Save Permalinks
Go to:
WordPress Dashboard → Settings → Permalinks
Click:
Save Changes
You do not need to change anything. Just saving refreshes rewrite rules.
Step 4: Clear Cache
Clear all cache layers:
LiteSpeed Cache
WP Rocket
Cloudflare
Server cache
Browser cache
If you are testing on a staging subdomain, clear that subdomain cache too.
Step 5: Test Profile URL
Test old URL:
https://example.com/members/webdevayon/
Then test new URL:
https://example.com/@webdevayon/
The new URL should show the same BuddyBoss profile page.
Why This Code Avoids Redirect Loops
A redirect loop usually happens when:
/@username/
is internally changed to:
/members/username/
Then BuddyBoss checks the user profile URL and tries to redirect it back to:
/@username/
Then the process repeats.
This part prevents that:
if (!empty($_SERVER['BB_AT_PROFILE_REQUEST'])) {
return $domain;
}
It tells BuddyBoss:
“While loading an internal @username request, keep the original BuddyBoss member domain.”
That is the key fix.
Optional: Redirect Old /members/username/ URLs
After everything works perfectly, you may want to redirect old profile URLs to the new format.
Add this only after testing the main code:
/**
* Optional: Redirect old /members/username/ URLs to /@username/
*/
add_action('template_redirect', function () {
if (!empty($_SERVER['BB_AT_PROFILE_REQUEST'])) {
return;
}
$uri = $_SERVER['REQUEST_URI'] ?? '';
if (preg_match('#^/members/([^/?]+)(/[^?]*)?(\?.*)?$#', $uri, $m)) {
$username = sanitize_title($m[1]);
$extra = $m[2] ?? '/';
$query = $m[3] ?? '';
wp_redirect(home_url('/@' . $username . $extra . $query), 301);
exit;
}
}, 10);
Only use this if your /@username/ page is already working.
Final Result
Before:
https://hollaappmenow.com/members/webdevayon/
After:
https://hollaappmenow.com/@webdevayon/
This gives your BuddyBoss community a cleaner, social-media-style profile URL structure while still using the original BuddyBoss profile system in the background.



