Hide user of one group from another in search

AI-generated summary

The discussion revolves around restricting user visibility between groups in search. Ankur_Tyagi wants to prevent users from Group A from searching and viewing users from Group B. ondrej suggested changing a group setting to restrict external users from seeing group members, but this does not solve the issue as users can still be found in the global search. Ankur_Tyagi already has this setting applied and is seeking a more specific solution. Moin believes a plugin might be necessary to achieve this and shared a related topic on the Discourse meta forum: https://meta.discourse.org/t/all-users-are-visible-in-mentions-autocomplete-list/232147/2?u=moin.

hi, I created two group, Group A and Group B and each group has a list of users. Now If I am logged in as Group A and search a user from Group B in global search option, can I restrict this?

In simple words, users of Group A should not be able to search any user from Group B or any other group.

This is the search I am talking about. Screenshot attached below

Please share if this is possible.

If you change this setting in the group, only users in the group can see who is in the group. External users can’t see members.

If you search for a user on the site like in your screenshot, it wouldn’t identify what group they are in?

Thanks, I have this setting applied already, but this does not solve my issue.
If I search another group user in the search, it shows the user details, but not the group.
But I wish to hide one group user from another group user in the search.
Is that possible?

I think you would need a plugin doing that.
There are similar topics like All users are visible in @mentions autocomplete list - #2 by pfaffman. You will find more looking at the related topics.