Make WordPress Core

Opened 11 years ago

Last modified 3 weeks ago

#15145 reviewing enhancement

Add a wp_list_users() template tag

Reported by: greenshady Owned by: audrasjb
Milestone: 5.9 Priority: normal
Severity: normal Version: 3.1
Component: Users Keywords: has-patch needs-unit-tests
Focuses: template Cc:


Now that get_users() has been implemented (#14572), I propose we add a function called wp_list_users() that handles a basic list of users similar to wp_list_authors(). WordPress has long needed a function for handling this.

The arguments for the function would simply be the same arguments used for get_users(). The wp_list_users() function would basically be a function for outputting the HTML. The function should also have the ability to link to the user's archive page and output a link to the user's RSS feed.

This would make it easy for theme developers and users to be able to create a users list without a lot of PHP work.

An alternate idea might be to push a few more arguments into the wp_list_authors() function, but I don't think that's the best route to go since its primary function is to list users that have written posts.

Attachments (2)

15145.diff (4.3 KB) - added by rohan013 7 years ago.
Adds a new function wp_list_users() which is very similar to wp_list_authors except the 'optioncount' and 'hide_empty' args since they are not valid here.
15145.2.diff (4.3 KB) - added by Mte90 4 years ago.
patch refreshed

Download all attachments as: .zip

Change History (22)

#1 @scribu
11 years ago

  • Cc scribu added
  • Component changed from Users to Template

#2 @Utkarsh
11 years ago

  • Cc admin@… added

#3 @markjaquith
10 years ago

  • Milestone changed from Awaiting Review to Future Release

#4 @nacin
7 years ago

  • Component changed from Template to Users
  • Focuses template added
  • Keywords needs-patch added

Would need a patch.

7 years ago

Adds a new function wp_list_users() which is very similar to wp_list_authors except the 'optioncount' and 'hide_empty' args since they are not valid here.

#5 @rohan013
7 years ago

  • Keywords has-patch added; needs-patch removed

#6 @chriscct7
6 years ago

  • Keywords needs-refresh added

4 years ago

patch refreshed

#7 @Mte90
4 years ago

  • Keywords dev-feedback added; needs-refresh removed

This ticket was mentioned in Slack in #core by mte90. View the logs.

3 years ago

#9 @afercia
3 years ago

  • Keywords needs-refresh added

In 15145.2.diff naming a variable $return is potentially confusing, for better code readability I'd suggest to rename it. Also needs some minor coding standards.

This ticket was mentioned in PR #1059 on WordPress/wordpress-develop by Mte90.

4 months ago

  • Keywords needs-refresh removed

Add wp_list_users function.

Trac ticket: https://core.trac.wordpress.org/ticket/15145

#11 @Mte90
4 months ago

Refreshed also this one but is still missing unit tests

#12 @SergeyBiryukov
3 months ago

  • Milestone changed from Future Release to 5.8

#13 @audrasjb
5 weeks ago

  • Keywords needs-refresh added; dev-feedback removed
  • Owner set to audrasjb
  • Status changed from new to reviewing

I'm not super convinced by the style parameter. First it doesn't exist on related functions like wp_list_pages, second I don't think the function should output anything else than a list. But it would be nice to add a hook to help to filter the output, just like wp_list_pages does:

     * Filters the HTML output of the pages to list.
     * @since 5.8.0
     * @see wp_list_users()
     * @param string    $output      HTML output of the users list.
     * @param array     $parsed_args An array of user-listing arguments. See wp_list_users()
     *                               for information on accepted arguments.
     * @param WP_User[] $users       Array of the user objects.
    $html = apply_filters( 'wp_list_users', $output, $parsed_args, $users );

Also, the PR needs an @since mention :)

#14 @Mte90
5 weeks ago

Updated the patch with this feedback except for the style.

Maybe it is the case to move the style part to a function like get_the_term_list for users?

This ticket was mentioned in Slack in #core by mte90. View the logs.

4 weeks ago

#16 @audrasjb
4 weeks ago

@Mte90 ok the patch looks good to me, thanks for the update. By the way, there are some minor check failures on the proposed PR :)

#17 @Mte90
4 weeks ago

I saw that errors but they are not on the right lines and so on and I cannot rerun jobs to update the checks itself.

#18 @prbot
3 weeks ago

Mte90 commented on PR #1059:

I can't rerun the jobs as the linting is wrong as that lines are clean and report errors on the wrong lines.

#19 @desrosj
3 weeks ago

  • Keywords needs-unit-tests added; needs-refresh removed
  • Milestone changed from 5.8 to 5.9

Today is feature freeze for 5.8. Since a committer has not had a chance to review this one, I'm going to punt.

I'm putting this in 5.9 instead of Future Release, though. And I'll try to return to it in the next cycle.

@Mte90 I did push an update to your branch that should fix the coding standards issues! Also, it would be great if we could add some unit tests. Looks like wp_list_authors() has some. We could probably use those as a starting point.

#20 @Mte90
3 weeks ago

Thanks for the help I will check for the unit tests :-)

Note: See TracTickets for help on using tickets.