Custom User Field Enhancements

feedback

(Robin Ward) #1

As part of our work on Discourse 1.4 I spent some time enhancing user fields:

Dropdowns

One of our most requested featured for user fields was dropdowns, so now you can add them. The options can even be dragged and dropped for reordering!

Field ordering

For some users it was very important to display the fields in a particular order. In the latest Discourse builds, you can reorder the fields. Just use the up and down arrow buttons, and the fields will be displayed in the same order when the user signs up.


Extra fields in profile - dropdown selector
Is it possible to create custom dropdown type user field in discourse?
(Michael Downey) #2

This is exciting! Is it safe to assume that changing order of fields does not change their ID/names in the DB?


(Robin Ward) #3

Yes, there is a new position column that handles the sort order.


(Paolo G. Giarrusso) #4

Doesn’t seem actually working (In v1.4.0.beta8 +9). In the actual login dialog, users only see “Pick an option”, twice (see snapshot below). For required fields, they see no options instead.


(Lisa Wess) #5

Are there any plans to have a field that is a URL? We ask our users to share GitHub and SO profiles and would love those to be real links.


(Stephen) #6

We’re looking for this too. In our case though it’s for users to include their social profiles.

For URLs to work well however and not be abused, we really need to be able to specify a prefix so as to lock down the domain and have them just specify a username. Otherwise they could put any link in there.

Is this something you’re already considering @eviltrout?


(Jeff Atwood) #7

This is not something we are considering at this time. People can add URLs via the “About Me” field, and we have significant protection in that field.


Link user field type
(Lisa Wess) #8

@steve_pd Yes, this would be perfect. We’d love to add social media too and saying what the domain would be (or even having that part non-editable) would be a fantastic solution. That would take care of having to moderate these closely as well.

@codinghorror - people in our community simply do not offer that information without prompting. Since adding those custom fields we have a lot more ‘opt-in’ to sharing those profiles. I very much hope you’ll reconsider this.


(Tobias Eigen) #9

I love these changes @eviltrout - thanks for paying attention to custom user fields which can be massively useful.

A feature request: would it be possible to set a user field to be used for the user’s title? I’d like to fill it with the name of the user’s affiliated organization as a link to their organization profile, as populated via SSO.

I can see others using it similarly to display some useful bit of info on user cards and profiles that is otherwise not standard in discourse.


(Kane York) #10

I think it would be more useful for you have the SSO payload specify the title. Which might already be available?


(Paolo G. Giarrusso) #12

@eviltrout Sorry to insist, but did you notice my bug report? Am I the only one seeing this bug? This feature will be very important for me in a couple of months — we plan to use it to schedule ~500 first-year students (we plan to use Discourse as the course forum, and to have them register on Discourse to also access other services).


(Sam Saffron) #13

Is this a locale specific bug? Does it work when locale is set to English ?


(Paolo G. Giarrusso) #14

That forum is mostly in German, but: that screenshot was after setting the locale back to English, and I think also fields created after switching locale are affected (I might have to recheck). The forum was also first created with an English locale.

Since (I’m guessing) the feature works for you, I’ll try to dig deeper.


(Ionuț Staicu) #15

Besides selects, I think a repeatable field would be useful. Think like „social networks”: add facebook, add twitter, add whatever. It makes little sense to have a list of 50 social networks (i exaggerate, obviously!) fields into profile page (and on signup page).

On the other hand, this will make a bit harder badge assignment for filling a certain field, no?


(Jonathan) #16

We just found another (tiny) bug related to dropdowns. When changing the position of a dropdown field all the options were cleared.

Here is the PR suggesting a fix Preserve user-field options when updating user-fields by b-studios · Pull Request #3661 · discourse/discourse · GitHub


(Jonathan) #17

The bug is not locale specific and occurs when the field name contains special character:

Special characters that do work are german umlauts, comma, dot and space.

Special characters that do not work are parenthesis (i.e. “(” and “)”)!

EDIT Sorry, not sure what is going on. Parens seem also to work on my test-instance.

We fail to reproduce the bug in a fresh test-instance, running on the same commit as @blaisorblade’s instance that keeps showing the problem.


(Tillmann Rendel) #18

I’m working with @bstudios and @Blaisorblade. We reproduced the bug by enabling login required. Then, the data about dropdown user field options is not preloaded when nobody is logged in. For example, when registering …

Maybe the guardian ate the options?


(Jonathan) #19

I prepared a fix to this bug in: Use userfield serializer in json dump by b-studios · Pull Request #3662 · discourse/discourse · GitHub

Since this might be a security concern and I am limited in my knowledge of the guardian, I think it is important that some knowledgable people review the change carefully.

EDIT The fix now has been merged.


(Dan Fowler) #20

Hello,

Great feature! I’ve noticed that the position field only applies to the sign-up page, but not the /users/{username}/preferences page. Is there any way to have the position field respected on that page, too? As it is, it seems that the position of the custom field on /users/{username}/preferences is a function of the order in which the custom fields were created. Does that sound right?

Cheers,

Dan


(Robin Ward) #21

I’ve fixed this:

https://github.com/discourse/discourse/commit/4f8542008832da7f9138020c4c92e31963557b42