Adding Custom Fields via Plugin Outlet

In my custom theme, I am attempting to create custom user fields using the plugin-outlet at preferences/profile and I am part way there.

I have successfully inserted new custom fields into User Preferences, but the information I entered into the UI does not stick after clicking save.

For example, I created this checkbox like this:

       <script type="text/x-handlebars" data-template-name="preferences/profile"> [all the other code]
<div class="control-group pref-check1">
  <label class="control-label">I like beer</label>
  <div class="controls">
    {{input type="checkbox" name="check1" value="true" class="input-xxlarge"}}
  </div>
</div>
</script>

What do I need to do to save the info entered in the preferences UI (and then display it in the /user template)? Is this possible with a custom theme?


Why am I doing this?

I am aware that you can create custom user fields under settings. I have a 3-4 different types of user custom fields for which I want finer control over the visual display on the user profile. For example some fields are text and some are true/false.

Since all custom user fields have the same class this is difficult. And I find :nth-child() a pain.

So my goal is to insert them into the template and control their classes and display.

I am interested in guidance specific to my first question and to my larger goal.

Cheers

Update. I ended up accomplishing my end goal with CSS without too much pain.

I realize that creating custom fields outside of the UI provided is more complicated than what I described above. I would be interested in eventually learning how to do this if anyone can point me to the right resources.

Having a great time learning how to develop Discourse!

Thanks!

3 Likes

Discourse Cakeday adds some custom fields to the user profile.

Probably the best way to approach this is find where those custom fields are added in the code (both the Ember front-end and the Rails back-end).

4 Likes

Cool , will check it out. Many thanks !

1 Like

Where method is the creation of the field?
(redoing the plugin for myself)