# Can I activate my plugin only for those registered on the site?

**URL:** https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857
**Category:** Support
**Created:** [24 april 2019 om 13:48 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857 "2019-04-24T13:48:23Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [24 april 2019 om 13:48 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/1 "2019-04-24T13:48:23Z")

</div>

I would like to display the number of logged users (users online plugin) on the site only for logged users (my all members from trust 0-4).  
But I don’t know how to disable this plugin on the site for guest ?

Why is there no such thing as a user group or trust level (-1 ? ) for not registered - not logged in/guest users?  
How can I put it in the code?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [24 april 2019 om 13:52 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/2 "2019-04-24T13:52:18Z")

</div>

Did you try changing the “whos online display public” setting?

A list of all settings can be found here: [Discourse Who's Online](https://meta.discourse.org/t/whos-online-plugin-discourse-whos-online/52345)

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [24 april 2019 om 13:53 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/3 "2019-04-24T13:53:16Z")

</div>

Edit: Scratch this, see David’s post above. I didn’t realize a setting existed!

* * *

~~The simplest way would be to hide it using CSS, we add the anon class to the html tag when someone isn’t logged in.~~

```css
.anon #whos-online {
    display: none;
}

```

> [@eextra](#):
>
> Why is there no such thing as a user group or trust level (-1 ? ) for not registered - not logged in/guest users?

Because we don’t know who they are, so we couldn’t effectively put them into a group.

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [24 april 2019 om 13:57 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/4 "2019-04-24T13:57:54Z")

</div>

> [@awesomerobot](#):
>
> .anon #whos-online { display: none; }

Okay, thanks!

I’ll check it out right away, but I already have a question.  
Why can’t I define a user group as not logged in? Other forums allow this. I mean, they give them permissions (like ipb, mybb, Vbull)

What if I want to write my own plugin that only activates for anonymous users? Is it enough for me to have a css class or something else?

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [24 april 2019 om 14:06 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/5 "2019-04-24T14:06:18Z")

</div>

> [@eextra](#):
>
> Why can’t I define a user group as not logged in? Other forums allow this. I mean, they give them permissions (like ipb, mybb, Vbull)

oh I guess I see what you’re saying, this really isn’t a group though is it? A group has members. This would just be anyone who isn’t logged in. It’s kind of the lack of a group.

Are there other permissions you want to grant to anonymous users other than hiding whos online?

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [24 april 2019 om 14:21 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/6 "2019-04-24T14:21:15Z")

</div>

> [@eextra](#):
>
> What if I want to write my own plugin that only activates for anonymous users? Is it enough for me to have a css class or something else?

```plaintext
currentUser

```

You may need it in the plugin.

> **[Build software better, together](https://github.com/search?q=repo%3Adiscourse%2Fdiscourse+currentUser)**
>
> GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [24 april 2019 om 14:22 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/7 "2019-04-24T14:22:36Z")

</div>

> [@awesomerobot](#):
>
> oh I guess I see what you’re saying, this really isn’t a group though is it? A group has members. This would just be anyone who isn’t logged in. It’s kind of the lack of a group.
> 
> Are there other permissions you want to grant to anonymous users other than hiding whos online?

Yeah, there’s a lot of it. I would like for example the icons from the flag component ([Trust-Level Avatar Flair](https://meta.discourse.org/t/trust-level-avatar-flair/82656)) to appear only when users logged in.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [24 april 2019 om 14:24 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/8 "2019-04-24T14:24:00Z")

</div>

You can target the anon class to hide pretty much anything from anonymous users.

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [6 mei 2019 om 07:38 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/9 "2019-05-06T07:38:04Z")

</div>

> [@Stranik](#):
>
> currentUser

So do I understand that a command is enough, or do I have to add some parameters?

```
    const currentUser = this.currentUser;
    if (!currentUser) {
      return;
    }

```

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [6 mei 2019 om 17:26 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/10 "2019-05-06T17:26:03Z")

</div>

Yes, I think that’s enough.

> <https://github.com/discourse/discourse/blob/f3d0d8fe7ddd1130d835ecdad86b7cd1cd4bc45e/app/assets/javascripts/discourse/components/watch-read.js.es6#L6>

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [7 mei 2019 om 05:10 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/11 "2019-05-07T05:10:42Z")

</div>

Do I need to edit the plugin and rebuild the forum to make such a simple change or can I do it from the admin panel in the head or footer section. Is it possible?

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [1 september 2022 om 05:03 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/12 "2022-09-01T05:03:24Z")

</div>



---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [1 september 2022 om 11:01 UTC](https://meta.discourse.org/t/can-i-activate-my-plugin-only-for-those-registered-on-the-site/115857/13 "2022-09-01T11:01:36Z")

</div>


