Opened 3 years ago
Last modified 3 years ago
#55071 new feature request
Add filters to wp_list_users()
Reported by: | tmatsuur | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | Users | Keywords: | has-patch |
Focuses: | Cc: |
Description
The wp_list_users function has been added in version 5.9.
In the source code of this function, the full name is "first_name last_name".
Japanese people's full names are usually "last_name first_name" and it would be useful to have a filter for full names.
$name = apply_filters( 'wp_list_users_fullname', "$user->first_name $user->last_name", $user, $args );
Attachments (4)
Change History (10)
#2
@
3 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Summary changed from Add a filter for fullname in wp_list_users() to Add filters to wp_list_users()
I think there's an opportunity here do add a couple more filters,
Some thoughts:
- Allow filtering the query args passed to
get_users()
(see also #55076) - Remove the detailed PHPDoc for the
$args
param and just point toWP_User_Query::prepare_query()
, likeget_users()
does. - Add filter for the full name option, as you suggest.
@
3 years ago
Sorry I forgot to add filter hook for get_users() args, so adding another patch for this
#3
@
3 years ago
Thanks for contributing a patch here!
Please note that filters need to be documented appropriately as per our guidelines, see https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#4-hooks-actions-and-filters.
Also, apply_filters( 'wp_list_users', $args );
on its own does not do anything. You would need to do $args = apply_filters( 'wp_list_users', $args );
for it to have any effect.
You might want to try submitting your change as a GitHub pull request so that you'll get notified if there's anything wrong with inline documentation and things like that. Makes everything a bit easier.
@
3 years ago
doc blocks added, moreover I remove the $args from wp_list_users_fullname filter because I think we don’t need this $args parameter just for changing a name
@
3 years ago
Sorry for another patch there was a mistake in doc block so I just fixed it and adding this patch
#4
follow-up:
↓ 5
@
3 years ago
Thanks @swissspidy @rafiahmedd
Thank you for changing the summary and creating the patch.
I don't think $args is a must-have feature either. However, in the WordPress source code, there are many filters whose parameters are added when upgrading.
That's a good thing, because there are many cases where the more information you have, the more helpful it is for the user of the filter, and I would like to have room to change the processing depending on the contents of $args.
#5
in reply to:
↑ 4
@
3 years ago
Replying to tmatsuur:
Thanks @swissspidy @rafiahmedd
Thank you for changing the summary and creating the patch.
I don't think $args is a must-have feature either. However, in the WordPress source code, there are many filters whose parameters are added when upgrading.
That's a good thing, because there are many cases where the more information you have, the more helpful it is for the user of the filter, and I would like to have room to change the processing depending on the contents of $args.
@tmatsuur welcome, I will wait for @swissspidy confirmation if he also confirms that $args is needed here then I will update a new patch.
Thanks, both of you 😊
#55076 was marked as a duplicate.