# Plugin to show full name only to users of the same group

**URL:** <https://meta.discourse.org/t/plugin-to-show-full-name-only-to-users-of-the-same-group/203813>\
**Category:** Development\
**Created:** [September 17, 2021, 12:58pm UTC](https://meta.discourse.org/t/plugin-to-show-full-name-only-to-users-of-the-same-group/203813 "2021-09-17T12:58:14Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![matewka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/matewka/32/163418_2.png) [@matewka](https://meta.discourse.org/u/matewka)\
**Post date:** [September 17, 2021, 12:58pm UTC](https://meta.discourse.org/t/plugin-to-show-full-name-only-to-users-of-the-same-group/203813/1 "2021-09-17T12:58:14Z")

</div>

Hi everyone,

I’m googling my problem for a few weeks already and I’m pretty close to giving up.

The background:  
I develop and maintain a multi-tenant admin panel for sport clubs.  
My self-hosted discourse forum is available only to members of those clubs. I would like it to be open for public. My own SSO integration automatically assigns users’ full name from my database to the discourse user once logged in.

The problem:  
Right now I cannot make my forum public because the full name of a user should be only visible to users of the same club.

My experience as a Ruby developer is zero (I’m a JS dev) but so far I’ve figured out this part of code:

```plaintext
# plugin.rb

after_initialize {
  require_dependency 'basic_user_serializer'
  require_dependency 'current_user'

  class ::BasicUserSerializer
    attributes :name

    def name
      # fixed set of group names that indicate belonging to a club
      clubGroups = Array['foo', 'bar', 'baz']
      
      # PART THAT I CAN'T FIGURE OUT:
      # Show the name of the user ONLY if they share one of the same of the currently logged user's `clubGroups`,
      # e.g. I'm logged in as a user who belongs to 'bar' group, meaning I belong to the Bar club. I should be able to see names of only those users who also belong to the 'bar' group
      ???

    end
  end
}

```

I can’t figure out the following things:

1. how to fetch current user’s groups
2. how to fetch featured user’s groups

Once I have the above, I could compare the 2 arrays with the `clubGroups` and decide wether to show the user’s name or not.

Another challenge for me will be turning off the possibility to edit your own name, but that’s a different story.

---

_[View the full topic](https://meta.discourse.org/t/plugin-to-show-full-name-only-to-users-of-the-same-group/203813)._
