1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Use the Username Instead of the Nickname for Direct Messaging

How to Use the Username Instead of the Nickname for Direct Messaging

Introduction

By default, BuddyBoss uses the user’s nickname when opening the direct message composer from a user profile. If you prefer to use the actual username instead, you can apply a small custom code change in your active theme.

Note: BuddyBoss does not provide a built-in setting for this behavior. The steps below use a custom workaround.

Custom Workaround

Before proceeding, make sure you have a complete site backup.

  1. In your WordPress admin dashboard, go to Appearance > Theme Editor.
  2. Under Select theme to edit, choose your active theme (preferably BuddyBoss Child Theme), then click Select.
  3. From the Theme Files list, click Theme Functions (functions.php).
  4. Paste the following code just before the closing PHP tag (?>):
function bb_override_button_message() {
    return apply_filters(
        'bp_get_send_private_message_link',
        wp_nonce_url(
            bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() )
        )
    );
}
add_filter( 'bp_get_send_private_message_link', 'bb_override_button_message' );
  1. Click Update File to save your changes.

Note: Any modifications like this are considered custom work. Please review the BuddyBoss Support Policy for details.

Troubleshooting and FAQs

Q: The message button still uses the nickname, what should I check?
A: Make sure the code is in the active theme’s functions.php and clear any caches.

Q: Should I add this code to the parent theme or child theme?
A: Use a child theme to avoid losing changes during updates.

Q: Will this affect existing messages?
A: No, it only changes how the recipient is populated when clicking the Message button.

Q: Can I revert this change easily?
A: Yes, remove the code from functions.php and save.

Q: Who can I contact for further assistance?
A: Check the BuddyBoss Support Policy or consult a developer.

Was this article helpful?

Related Articles

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

To speak to our Agency consultant, fill in the form found at our Contact Page.

  • Get Started

    Enter your name and email address to get started with your project...

  • This field is for validation purposes and should be left unchanged.