# Plugin for anonymize users

**URL:** <https://community.pexip.com/t/plugin-for-anonymize-users/154>\
**Category:** Web App Plugins\
**Tags:** webapp2\
**Created:** [November 24, 2022, 2:36pm UTC](https://community.pexip.com/t/plugin-for-anonymize-users/154 "2022-11-24T14:36:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcos.cereijo](https://dub1.discourse-cdn.com/flex005/user_avatar/community.pexip.com/marcos.cereijo/32/14_2.png) [@marcos.cereijo](https://community.pexip.com/u/marcos.cereijo)\
**Post date:** [November 24, 2022, 2:36pm UTC](https://community.pexip.com/t/plugin-for-anonymize-users/154/1 "2022-11-24T14:36:49Z")

</div>

I have created a new plugin and I think that it’s a good idea to let you know about it. The plugin was made for webapp 2 and I think that the way to do it could be interesting for implementing other use cases.

## Goal

We want to have a plugin that anonymizes all the users inside a VMR. This plugin should change the `display name` and the `overlay text` (the text that appears over the video). It will display a random string instead. For example, for a user it could display `anonymouse_5427`.

 ![Captura de pantalla de 2022-11-24 15-11-12](https://europe1.discourse-cdn.com/flex005/uploads/pexip/original/1X/9a602a41736b89251397c56eaafd0aa0ce91e3ee.png)

## How was it created

Create this plugin was a bit tricky. Change the `overlay_text` is easy. We have a method in `PexRTC` that does this. This method is `setParticipantText(uuid, newOverlayText)`. However, the method can be only used if the user is the host of the meeting and we can have several hosts in the same meeting. This means that we have to define some rules:

- If the user is the host of the meeting, he changes his own `overlay_text`.
- If the user is a guest, the `overlay_text` is changed by the first host that joined the VMR.

The previous method will change only the `overlay_text` and the name in the roster list won’t be modified. For that we will have to do some work.

The first step is to save in a variable the function `onParticipantCreate` and avoid to call that until we know that the `overlay_text` was correctly changed. This could happen in the following situaltions:

- If the user changed the `overlay_text` we can call it directly.
- If we detect that the `overlay_text` was already changed in `onParticipantCreate`.
- In any other case, we have to wait until receiving the `onParticipantUpdate` and we will override the participant data and trigger `onParticipantCreate`:

```auto
    (window as any).PEX.pexrtc.onParticipantUpdate = (participant: any) => {
      participant.display_name = participant.overlay_text;
      participant.uri = participant.overlay_text;
      onParticipantCreate(participant);
      onParticipantUpdate(participant);
    }

```

You can find the whole project in GitHub: [GitHub - pexip/plugin-anonymizer: Plugin that anonymize the user's display names.](https://github.com/pexip/plugin-anonymizer)

## Future development

For example, one thing that we could add to the plugin is to only anonymize if the VMR has a certain structure. For example, if it begins with `confidential-`.
