Opened 12 years ago
Closed 12 years ago
#20637 closed enhancement (fixed)
Change default display name for new users
Reported by: | mikelittle | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.4 |
Component: | Users | Keywords: | has-patch ux-feedback dev-feedback |
Focuses: | Cc: |
Description
As discussed on the wp-hackers mailing list here http://lists.automattic.com/pipermail/wp-hackers/2012-May/thread.html#43064
It has been suggested that the default display_name for a new user should be constructed from the supplied first name and last name.
Attached is a patch to implement this behaviour. There are three parts:
1) Move the assignment of the display_name (in wp_insert_user()) to be after the first_name and last_name are assigned in case any plugins hooked on their respective filters chooses to modify them.
2) Add the $userdata parameter (passed to wp_insert_user()) to the filter call
3) Add a default filter hooked to pre_user_display_name. This default filter will concatenate the first and last names with a space between (internationalized), only if the current display_name is empty and either of first or last is filled.
Attachments (1)
Change History (8)
#1
@
12 years ago
The $userdata context is not passed to the pre_user_* hooks in sanitize_user_field(). It would still work, but the intention for this to work on every save, or just create?
#2
@
12 years ago
It was certainly originally only discussed in the context of creating users.
I think that semantically, being called from sanitize_user_field(), it doesn't feel like it should be changing that field in the same way.
Given that the new default filter won't make any changes if not passed the $userdata array, I think that end is accomplished. (Even if not by original design ;-)
#5
@
12 years ago
- Milestone changed from Awaiting Review to 3.5
- Owner set to nacin
- Status changed from new to reviewing
#6
@
12 years ago
As the various pre_user_* filters are designed to complement the same filters in sanitize_user_field(), we probably shouldn't try to overload it otherwise. The patch also will never work, because $display_name is set to $user_login before getting passed to the filter, which means empty($display_name) in _wp_pre_user_display_name() will never be true.
Patch to implement described behaviour