Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User display names #1246

Merged
merged 3 commits into from
Sep 20, 2017
Merged

User display names #1246

merged 3 commits into from
Sep 20, 2017

Conversation

tobyzerner
Copy link
Contributor

@tobyzerner tobyzerner commented Sep 19, 2017

(I'm going into master here because I need to use this imminently for a client project.)

It is not uncommon for forums to be intergrated with sites where users don't have a unique "handle" - they might just have their first name, or a full name, which is not guaranteed to be unique.

This PR introduces the concept of "display names" for users. By default display names are just an alias for usernames, and they cannot be changed in core (we are not introducing a new column into the DB).

But extensions may override this and set them to something different. eg. the client integration I'm working on uses a numeric ID as the username, and adds a display_name column which is set to a non-unique first name.

The important thing is that all code should use display_name whenever intending to output a human-readable name - username is reserved for cases where you want to output a unique identifier (which may or may not be human-friendly) - eg. @mentions, user profile URL slugs.

The new "GetDisplayName" API is probably sub-optimal, but I didn't worry too much because we can come up with something better when we bring this into next-back.

Just wanting some feedback on the concept and implementation before I merge.

ref #557

It is not uncommon for forums to be intergrated with sites where users
don't have a unique "handle" - they might just have their first name,
or a full name, which is not guaranteed to be unique.

This commit introduces the concept of "display names" for users. By
default display names are the same as usernames, but extensions may
override this and set them to something different. The important thing
is that all code should use `display_name` whenever intending to output
a human-readable name - `username` is reserved for cases where you want
to output a unique identifier (which may or may not be human-friendly).

The new "GetDisplayName" API is probably sub-optimal, but I didn't worry
too much because we can come up with something better in `next-back`.

ref #557
@tobyzerner
Copy link
Contributor Author

tobyzerner commented Sep 19, 2017

Note that this is not the same thing as "screen names" as suggested in #557 (comment). A screen name (or "full name" might be a better name for it) extension which just wants to add an optional profile field, and preserve the username as the primary human-readable identifier, would not need to change the display name.

tobyzerner added a commit to flarum/mentions that referenced this pull request Sep 19, 2017
This also improves the behaviour of mentions in the JS preview (no more
broken links, mention is only picked up if corresponding user/post is
found).

See flarum/framework#1246

Closes flarum/framework#315
@tobyzerner tobyzerner added this to the v0.1.0-beta.8 milestone Sep 20, 2017
@tobyzerner tobyzerner merged commit eb72307 into master Sep 20, 2017
@tobyzerner tobyzerner deleted the display-names branch September 20, 2017 07:12
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request Mar 11, 2022
This also improves the behaviour of mentions in the JS preview (no more
broken links, mention is only picked up if corresponding user/post is
found).

See flarum/framework#1246

Closes flarum/framework#315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants