User custom field toggle for sidebar (SFW Mode)

What would you like done?

I need to add new button to Sidebar (or some other place possible to discuss too), which will simply toggle user’s custom field value. We set up “SFW” mode, by basically inverting this approach. But as the value is optional to set by user and the website is NSFW by default, it would take time for one user to get into their profile settings in order to find tiny and non-evident checkbox.

That’s why the idea of putting a button with two states (On/Off) which will change the custom field’s value for the user. The default state is NSWF (unchecked user’s field, or 0). The second state is SFW (checked user’s field)

When do you need it done?

It seems to me it should be a quick task for experienced theme-component developer :slight_smile: Take your time

What is your budget, in $ USD that you can offer for this task?

Name your price. Sounds like an easy job.

1 Like

Maybe I’m interested in this work?


I’m not sure if this is a question to anyone :slight_smile: Let’s work :slight_smile:


This theme-component maybe combined with welcome Link Banner?

1 Like

What an awesome theme-component User Field Prompt is! No matter how frequent I visit Discourse Meta, it’s always amazing to find something new about Discourse.

The task described is different from the concept of post fields. And it’s also not intended to play with other theme components like Welcome Link Banner you mentioned.

The maximum customization I see now is introducing basic customization options like:

  • Discourse Text-fields for admin to be able to Create/Update/Delete buttons based on example of numerous theme components like Custom Header Links (icons)

  • Admin could give button:

    • a Name (ID for CSS purposes)
    • SVG Icons names for both states (requires it to be present in font-awesome sprites or website custom SVGs)
    • Custom field ID
1 Like

Okay haven’t played with it yet. but there is also page publishing.

I would imagine the code may help to get some ideas. There are a few components that use user fields. A more recent addition is a kind of watched words for the member that will hide? posts with word term.

There are also some theme-components that use a switch toggle in iirc Hamburger menu or header.

Custom header links may work as well possibly.

I am not sure but with a checkbox? you might be able to copy the link for that user prefer checkbox.

Sorry, I lost you on the first couple of sentences as I don’t think these are related to the topic above.

P.S. You have SSL certificate expired for the website in your Bio :unlock:

1 Like

Thanks need to update the site address. The client changed to .com. :facepalm:

The idea I meant above. You could look at the source fir the User field prompt to get an idea for the code you need to toggle your nsfw user setting. Then look at maybe something like the Thene-component Light/Dark toggle and combine ideas for the toggle to manipulate your nsfw user setting.

Okay, now I get it. Well, you seem to be inventing the wheel of this solution I mentioned in the first post: Our solution for blurring NSFW content

It does what you talk about. Looks into the user’s field value and sets CSS class via JS. Please make sure you use the code from this message as the base one, because the one used in the first post there relies on deprecated Discourse methods.

In addition, you can look into this: CSS Classes for Current User's Groups to adjust the look & functionality of your website based on user’s groups :slight_smile:

1 Like

As for toggle itself, and your reference to Dark/Light toggle, I guess it may be interesting to look into it for the future developers of this component I’d like to share to public as soon as it’s finished. @Lhc_fl is working now on something and we will hopefully be able to test it ourselves in production first :slight_smile:


That is quite cool. I am still very much a novice learning coding. Still quite a bit to learn.

From what I have seen Lhc_fl is very talented.

1 Like

It’s done: Sidebar User Field Toggle

Yep Reaction GIF by C H A R L Ö T T E

Thank you, @Lhc_fl :heart:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.