# Poll Defaults

**URL:** https://meta.discourse.org/t/poll-defaults/268399
**Category:** Theme component
**Tags:** polls, deprecated
**Created:** [June 15, 2023, 3:52am UTC](https://meta.discourse.org/t/poll-defaults/268399 "2023-06-15T03:52:24Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [June 15, 2023, 3:52am UTC](https://meta.discourse.org/t/poll-defaults/268399/1 "2023-06-15T03:52:24Z")

</div>

| | | |
| --- | --- | --- |
| ℹ | **Summary** | Sets the defaults for polls within Discourse |
| 🛠 | **Repository** | [GitHub - nathan-nz/discourse-poll-defaults: Sets the defaults for polls within Discourse · GitHub](http://github.com/nathan-nz/discourse-poll-defaults) |
| ❓ | **Install Guide** | [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682) |
| 📖 | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

Install this theme component

This simple theme component allows some control over the default poll behaviour. It was inspired by this Topic:

> [@Making polls ‘Show who voted’ by default](https://meta.discourse.org/t/changing-the-default-settings-when-users-build-polls/220022):
>
> In my community folks always want to see who voted on a poll, but… they always seem to forget to select the check-mark Show who voted. Is there any way to set this as a default?

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/9/f/e9f318c1026b10516780acd70aa19067de51a3db.png)

Other settings could easily be added if needed.

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [June 15, 2023, 12:42pm UTC](https://meta.discourse.org/t/poll-defaults/268399/2 "2023-06-15T12:42:20Z")

</div>

THANK YOU! I’ve already got this installed on my forum and I’m looking forward to fewer “Oops” moments for the folks who participate on our forum.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [September 23, 2023, 2:57am UTC](https://meta.discourse.org/t/poll-defaults/268399/3 "2023-09-23T02:57:38Z")

</div>

This looks to be broken at the mo:

> [@Overriding poll default so "public=true"](https://meta.discourse.org/t/overriding-poll-default-so-public-true/279722/8):
>
> I don’t think it’s working on my test site now either. It may need updating to account for some recent changes? I’ll split this off into a #dev topic +1

I’ll take a look when I get the chance, but PRs are always welcome!

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [November 8, 2023, 3:46am UTC](https://meta.discourse.org/t/poll-defaults/268399/4 "2023-11-08T03:46:52Z")

</div>

@nathank

I was looking at this code:

> <https://github.com/nathan-nz/discourse-poll-defaults/blob/main/common/header.html>

I think you can do the following:

```js
api.modifyClass("component:modal/poll-ui-builder", {
  pluginId: 'poll-defaults',
  didInsertElement() {
    this._super(...arguments); // super.didInsertElement(...arguments); doesn't work (?)

    if (settings.Public) {this.set('publicPoll', true)}
    if (settings.Advanced) {this.set('showAdvanced', true)}
  }, 
});

```

It works.

However, I’m perplexed with `didInsertElement`.  
`poll-ui-builder` is now a glimmer component. `didInsertElement` is not supposed to exist based on the [ember upgrading guide](https://guides.emberjs.com/release/upgrading/current-edition/glimmer-components/#toc_lifecycle-and-properties).  
I can see in core some [usage](https://github.com/search?q=repo%3Adiscourse%2Fdiscourse%20super.didInsertElement(...arguments)%3B&type=code). Maybe some specificity in Discourse?  
Also, I’m not sure why `super.didInsertElement` doesn’t exist in this above code context.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 13, 2023, 7:52am UTC](https://meta.discourse.org/t/poll-defaults/268399/5 "2023-11-13T07:52:38Z")

</div>

This is now part of core: 🥳

[https://github.com/discourse/discourse/pull/24332](https://github.com/discourse/discourse/pull/24332)

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [November 14, 2023, 5:28am UTC](https://meta.discourse.org/t/poll-defaults/268399/6 "2023-11-14T05:28:18Z")

</div>

Nice!! This makes the TC nicely obsolete. I consider this mission accomplished 😉

---

<div class="post-metadata">

### Author: ![meave](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@meave](https://meta.discourse.org/u/meave)
#### Post date: [December 1, 2023, 12:26pm UTC](https://meta.discourse.org/t/poll-defaults/268399/7 "2023-12-01T12:26:12Z")

</div>

So .. how do we change the default to private ?

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [December 1, 2023, 12:32pm UTC](https://meta.discourse.org/t/poll-defaults/268399/8 "2023-12-01T12:32:16Z")

</div>

There is a site setting

> [@New in Discourse 3.2.0.beta4: polls default to public](https://meta.discourse.org/t/new-in-discourse-3-2-0-beta4-polls-default-to-public/285282/1):
>
> To change the default back to private, forum administrators can toggle the ‘poll default public’ site setting.

---

<div class="post-metadata">

### Author: ![meave](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@meave](https://meta.discourse.org/u/meave)
#### Post date: [December 1, 2023, 11:46pm UTC](https://meta.discourse.org/t/poll-defaults/268399/9 "2023-12-01T23:46:43Z")

</div>

Thanks !
