Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to hide certain users from the “To” field in Buddypress private messaging?


  • stephunique
    Participant

    @stephunique

    Hello all,

    I have hidden myself as an admin, on my test site running buddypress, for obvious reasons. However, I discovered that when composing a message using Buddypress messages, when the user types in a partial name of the recipient, even a single letter, everyone that matches that name will show up, even if they are hidden from the directory. For example, typing “@a” will show “@admin” (me) as well as “@adam” or “@amanda” and this is no good.

    Is there a way to remove certain users (ideally by user roles) from showing up in the “to” field?

    I have WordPress 6.6.1 and Buddypress 14.0.0.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)

  • Mike Witt
    Participant

    @mike80222

    Interesting. I never knew about this. I gave it a try and on one of my sites when I type in a letter a bunch of users come up. But they don’t all have that letter in their name. But when I put in the @, I don’t get anything. On another site this doesn’t do anything at all.

    We’re talking about Profile -> Messages -> Compose, right?

    I wonder how this is implemented? Maybe someone more familiar with the BP documentation can provide a pointer to something that talks about it.


    emaralive
    Participant

    @emaralive

    @mike80222, when composing a message, the “@” applies to the BuddyPress Nouveau template pack, i.e, the label reads “Send @Username” as opposed to the BuddyPress Legacy template pack that reads “Send To (Username or Friend’s Name)” and I’m not sure why it is not the same for both but, that is current behavior. As to the inconsistency for when suggestions appear or not appear is a puzzle, at the moment.

    @stephunique, it is possible to filter the suggested usernames by utilizing the bp_core_get_suggestions filter. If you only want to apply this filtering to messages (compose) then your callback needs to be location aware (what/which page/screen is active/loaded), as well.


    Mike Witt
    Participant

    @mike80222

    Ah, OK. I am using Legacy, so that explains the @. I wouldn’t worry about the other thing if it’s just me seeing it. Good to know about bp_core_get_suggestions.


    stephunique
    Participant

    @stephunique

    @mike80222

    We’re talking about Profile -> Messages -> Compose, right?

    Yes, this is exactly what I am talking about.


    @emaralive

    Thank you for this suggestion and interesting insight. I am not a developer so I have no idea how to write a script that does this, but I found this code here. Would you/does anyone know if this is the right thing to use, and if so, how I can modify it to apply only to the “compose a message” page? And I am guessing I need to put it in the bp-custom.php file?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar