Enable voting just for certain group of people

Hello.

I was wondering if there is a way, even if it’s not official, to enable the plugin for just a few users.

We have a specific need to enable voting for affiliates, who fulfills certain criteria. Would be nice to be able to create some kind of group and just enable the plugin for them only.

Thanks a lot in advance.

hmm… that does seem to be a feature request. I don’t see an admin setting to limit by group or even trust level.

What’s the problem you’re trying to solve? If you’re trying to limit a poll to a group you could create a category only the group can see and create the poll topic in there.

Why? Just create a poll in a category that only this group has access to.

1 Like

Well, you could achieve this by granting 0 votes to all trust levels below, say, TL3 or TL2. That would effectively disable voting for those users.

Speculating here, but I can understand the appeal of letting everyone see what’s being voted on, and how the votes are being cast, even if not everyone can vote. Kinda like how parliaments work.

7 Likes

Correct me if I’m wrong, but I’d assume that voting requires write access in the category where the poll is, so you’d grant write access to the group that can vote and read permission to everyone else, no?

I don’t think so – given that I believe this isn’t about polls, but about the topic voting plugin, I think you can vote on a topic without being able to post in that category.

Is this true ?

I also would like to create a Poll where only write-access member can vote and read access only see.

No, it’s not possible. Actually if a user have a “see” permission in the category setting, he/she can also vote a poll or use the voting plugin.

6 Likes

Ok at least, is it possible to hide the topic to people who are not “logged in” ?

You can do it in various ways but since your goal is to make a single topic (or some topic) invisible to non-registered users, you can do something simple:

  • create a new category
  • change the category permission (Security tab), delete everyone and add trust_level_0. Every user that have an account can see that category (and the topics inside), non-logged in users can see all the rest except that category.
3 Likes

Mind you… this is very easy to bypass for someone with a bit of knowledge.

That being said, if all the people you want to be able to vote are members of a group(s), you can “disable” or hide the vote button from everyone else with CSS.

Note the quote marks on the word disable, you’re not really disabling anything here, this is purely visual.


Discourse adds group classes to the body that match user groups

The class added follows this naming structure:

.primary-group-GROUP_NAME

So .primary-group- is a prefix added to the group name and spaces in the group name change to underscores.

you can use those as CSS selectors.

For example if the people you want to have the ability to vote all fall under the group name Awesome People

Then the selector would be .primary-group-awesome_people

Now that you know the selector, you need to invert it to hide / disable the button from everyone but those people in that group


So first you select body

Like so:

body {
	// styles
}

then qualify it with the group name like so

body:not(.primary-group-awesome_people) {
	// styles
}

The you add the vote button to the selector:

body:not(.primary-group-awesome_people) .vote-button {
	// styles
}

Then you finally add your styles, you have to options here, either remove the button with display:none or “disable” clicking it with pointer-events: none;

So the final result would be either:

body:not(.primary-group-awesome_people) .vote-button {
	display:none
}

Or

body:not(.primary-group-awesome_people) .vote-button {
	pointer-events: none;
	user-select: none;
}

You can also use more than one group like so:

body:not(.primary-group-awesome_people):not(.primary-group-car_owners):not(.primary-group-chefs)
	.vote-button {
	pointer-events: none;
	user-select: none;
}

And that would only “allow” members of the Awesome people, Car Owners, and chefs groups to be able to click / see the voting button.


Also, note that I have not tested this extensively but would be happy help if issues come up.

3 Likes